Html CSS中的对齐/边距
为什么下面这些看起来什么都不做Html CSS中的对齐/边距,html,css,margin,alignment,Html,Css,Margin,Alignment,为什么下面这些看起来什么都不做 <style> form { margin-left:auto; margin-right:auto; } h1 { margin-left:auto; margin-right:auto; color : #2265FF; } </style> <body> <h1>Please type
<style>
form {
margin-left:auto;
margin-right:auto;
}
h1 {
margin-left:auto;
margin-right:auto;
color : #2265FF;
}
</style>
<body>
<h1>Please type in the text to be converted!</h1>
<form> ... </form>
形式{
左边距:自动;
右边距:自动;
}
h1{
左边距:自动;
右边距:自动;
颜色:#2265FF;
}
请键入要转换的文本!
...
显然,我还有更多的HTML要处理
在CSS3中是否有更好的方法来实现这一点
谢谢 您最好使用
文本对齐:居中
,因为默认情况下
和
将其宽度设置为100%
。在CSS3中,您可以执行以下操作:
form, h1 {
display: table;
margin: 0 auto;
}
如果要支持较旧的浏览器,则需要指定宽度:
form, h1 {
width: 500px
margin: 0 auto;
}
但是如果你把它应用到一个父容器上会更好
.container {
margin: 0 auto;
width: 500px;
}
<div class="container">
<h1></h1>
<form></form>
</div>
.container{
保证金:0自动;
宽度:500px;
}
您想做什么?请提供更多信息。你到底想做什么?请你详细说明一下好吗?也许展示一下这个应用到的HTML是个好主意。