【发布时间】:2013-02-01 13:48:27
【问题描述】:
我正在尝试为在左栏中有徽标、在右侧有旋转图像横幅和顶级导航的网站制作标题,而不使用浮动。我在这里做错了什么?
这是我想要的样子:
这是我的 HTML:
<!doctype html>
<head>
<title></title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div id="header">
<div id="logo"><p>Logo</p></div>
<div id="right">
<div id="rotator"><p>Rotator</p></div>
<div id="navigation"><p>Navigation</p></div>
</div>
</div>
</body>
</html>
这是我的 CSS:
#header{
width: 1024px;
margin-left: auto;
margin-right: auto;
background-color: yellow;
top: 10px;
font-size: 0px;
}
#logo{
display: inline-block;
background-color: red;
width: 306px;
height: 192px;
font-size: 0px;
}
#right{
display: inline-block;
background-color: black;
width: 718px;
height: 192px;
font-size: 0px;
}
#rotator{
display: block;
background-color: green;
width: 718px;
height: 132px;
}
#navigation{
display: block;
background-color: blue;
width: 718px;
height: 60px;
}
p{
font-size: 24px;
margin:0;
padding: 0;
}
这就是它最终的样子:
【问题讨论】:
-
你为什么不想使用浮点数?
-
部分作为练习,看看是否可以完成,也因为我不太喜欢花车。在我看来,它们很混乱,并且在您的页面上有一个“没有”高度的元素可能会令人沮丧。通过消除浮动,我可以消除对 clearfix 的需要。
标签: html css layout stylesheet