日期:2014-05-16  浏览次数:20559 次

CSS:一个元素可以设置多个height?怎么使用?
CSS:一个元素可以设置多个height?怎么使用?其中body、footer等的高度到底是哪个?部分代码如下:
#header,#footer
{
width:85%;
margin:0 auto;
height:50px;
}
#header
{
height:70px;
margin-top:5px;
border:solid 1px #000;
background:url() no-repeat right -20px;
}
#header h1
{
line-height:40px;
}
#body
{
position:relative;
width:85%;
margin:3px auto;
height:100%;
}
#sidebar
{
position:absolute;
left:0;
top:0;
width:200px;
}
#right
{
width:240px;
position:absolute;
right:0;
top:0;
}
#center
{
margin:0 241px 0 201px;
}
#body,#sidebar,#right,#center,#footer{height:750px;border:solid 1px #000;}
#footer
{
height:50px;
}
#body
{
border:none;
}
------解决方案--------------------
定义多少个高度都是没有的 以最后一个为准
#footer height:50px;
#body height:750px;
------解决方案--------------------
css中,如果没有重要层次说明的话 !important 修饰,默认后来的样式覆盖掉之前定义的相同属性样式

如果多模块协作开发,如果是多人协作,也许便会出现,样式重复定义的问题