这是一个好主意,样式的身体标签? [英] Is it a good idea to style the body tag?

查看:79
本文介绍了这是一个好主意,样式的身体标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的固定网站上,我有一个类似下面的布局:

 < div id =wrapper > 
< header> ...< / header>
< div id =content> ...< / div>
< footer> ...< / footer>
< / div>

我的CSS类似于:

  #wrapper {
width:700px;
margin-left:auto;
margin-right:auto;
}

< body> 标签的方式也是可行的,它使我的代码更可读,因为我没有嵌套< div> 标签。



是否向< body> 一个安全的想法应用边距和固定值?

c> c>


$ b

$ b

对于你的布局,你可能还是想使用 #wrapper (看起来像一个固定宽度的布局),因为你可能想为< c $ c> body (或使用可见的空空格)。


In my fixed-width website, I have a layout similar to this:

<div id="wrapper">
  <header>...</header>
  <div id="content">...</div>
  <footer>...</footer>
</div>

And my CSS is similar to this:

#wrapper {
  width: 700px;
  margin-left: auto;
  margin-right: auto;
}

Styling the <body> tag the same way also works, and it makes my code more readable, as I have less nested <div> tags.

Is applying margins and a fixed with to the <body> a safe idea?

解决方案

It is perfectly safe, body is an HTML element like all the others.

For your layout, you might still want to use #wrapper (seems like a fixed width layout), because you might want to set a background for body (or do something with the visible "empty" space).

这篇关于这是一个好主意,样式的身体标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆