我是一个新手的CSS。我只是画一个基本的HTML页面下面的代码:如何优化这个CSS代码?
<html>
<head>
<title>Hey</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<header class="top-menu"></header>
<div class="container">
<div class="left-side"></div>
<div class="main-content"></div>
</div>
<div class="foot"></div>
</body>
</html>
这里是style.css中:
.top-menu{
position: fixed;
top: 0;
left: 70px;
right: 70px;
height: 50px;
background-color: #000000;
}
.container{
margin: 70px 70px 20px 70px;
display: inline-block;
width: 91%;
}
.left-side {
width: 30ex;
min-height: 30ex;
float: left;
background-color: blue;
}
.main-content {
width: 80ex;
float: right;
background-color: red;
min-height: 100ex;
}
.foot {
background-color: green;
height: 5ex;
width: 91%;
margin-left: 10ex;
}
目的是straightforward.But的CSS看起来crap.even一些problems.I要问一些问题:
1.容器的左右边距是70px,和top-menu一样,但是从chrome页面视图来看,它为什么不对齐?
2.当我将'容器'的宽度设置为100%(与脚部相同)时,为什么会出现水平滚动条?
3.如果我没有将容器的显示器设置为“内嵌块”,为什么脚部会飞到空中? (即使我将其设置为“块”)
4.Could你们给我一个更好的CSS样式代码?
感谢您的建议。我刚刚从所有元素中获得了所有最小高度的乘积。我必须陈述容器的原因是,如果我刚获得显示属性的乘积,那么脚部分将与容器部分重叠。有任何想法吗? – LeoShi
现在没有那么多人使用IE6/7了。 0.3&IE6和1.2%IE7。大多数IE用户使用IE8,但OP总是可以使用类似ie9.js的东西来强制与HTML5元素兼容。 – Kyle
谢天谢地,不超过0.3%使用IE6。我只是在暗示html5的采用需要时间,而在这个过渡时期,我们必须警惕某些html标签“”,它可能无法按预期工作。 –
ProfileTwist