现在通常满足于以一定尺寸居中。
<html>
<head>
<style type="text/css">
#content { margin: auto; width: 960px;}
</style>
</head>
<body>
<div id="content">Blah!</div>
</body>
</html>
不对对齐和大小使用包装器并将其直接应用于 body
标签是否安全? 像这样:
<html>
<head>
<style type="text/css">
body { margin: auto; width: 960px;}
</style>
</head>
<body>
Blah
</body>
</html>
最佳答案
大小是安全的,但是 margin: auto
居中并不完全。
您必须将 text-align: center
添加到 body 样式,以便在 IE6 中也将其居中。 (是的,我知道,这完全没有意义,但这就是 IE6 的工作原理)
关于html - 指定主体 CSS 宽度是否安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4986836/