样式.css
body {
background-color: #666666;
margin-left:500px;
margin-right:500px;
margin-top:10px;
margin-bottom:20px;
font-family:Verdana, Geneva, Tahoma, sans-serif;
font-size:12px;
color:white;
}
div.header {
background-color: #333333;
}
div.navigationBar {
border:0;
border-style:solid;
background-color:#112211;
}
div.navigationButton {
border:1px;
border-color:#ffffff;
border-style:solid;
background-color:#112211;
padding:15px;
width:100px;
height:40px;
text-transform:uppercase;
overflow:hidden;
font-weight:bold;
text-align:center;
}
.navigationBar ul {
list-style-type:none;
padding:1px;
}
.navigationBar li {
display:inline;
float:left;
}
.navigationButton a
{
text-decoration:none;
color:#eec600;
display:block;
}
.navigationButton a:link {
text-decoration:none;
}
.navigationButton a:hover {
color:#ffe811;
}
索引.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content="pl" http-equiv="Content-Language">
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<div class="header" style="height:200px; width: 800px;"></div>
<div class="navigationBar" style= "height:73px; width: 800px;" > /* added unit to the height property */
<ul>
<li><div class="navigationButton" ><a href="#link1">Button1</a></div></li>
<li><div class="navigationButton" ><a href="#link2">Button2</a></div></li>
<li><div class="navigationButton" ><a href="#link3">Button3</a></div></li>
</ul>
</div>
</body>
</html>
为什么header div和navigationBar之间有差距?欢迎对我的代码提出其他意见和建议。
可悲的差距发生在网络浏览器中(为什么不在 jsFiddle 中?),我在 Firefox 和 IE 中尝试了这段代码。