specified body CSS width is safe?

耗尽温柔 提交于 2019-12-10 13:06:11

问题


Now very often content with a certain size centered.

<html>
<head>
  <style type="text/css">
    #content { margin: auto; width: 960px;}
  </style>
</head>
<body>
   <div id="content">Blah!</div>
</body>
</html>

Is it safe to not use a wrapper for alignment and size, and apply it directly to a body tag? Like this:

<html>
<head>
   <style type="text/css">
      body { margin: auto; width: 960px;}
   </style>
</head>
<body>
   Blah
</body>
</html>

回答1:


The size is safe, however the margin: auto-centering isn’t completely.

You have to add text-align: center to the body style to center it in IE6, too. (Yeah, I know, it totally makes no sense, but that’s hoe IE6 works)



来源:https://stackoverflow.com/questions/4986836/specified-body-css-width-is-safe

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!