I have the following page:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Title</title>
<link rel="stylesheet" href="css/common.css">
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<div id="page">
<div id="header">
<ul id="menu">
<li class="products">
<a href="products.html">Products</a>
</li>
<li class="resume">
<a href="resume.html">My resume</a>
</li>
<li class="blog">
<a href="blog.html">Blog</a>
</li>
<li class="about">
<a href="about.html">About</a>
</li>
</ul>
</div>
<div id="main">
</div>
<div id="footer">
</div>
</div>
</body>
</html>
Index.css:
#page {
width: 1024px;
height: 900px;
margin:0 auto;
}
#header {
width:870px;
}
#menu {
border-bottom: 1px solid #EEEEEE;
border-top: 1px solid #EEEEEE;
clear: both;
list-style-type: none;
margin: 20px 0;
overflow: hidden;
padding: 11px 0 11px 34px;
width: 870px;
}
#menu li {
float: left;
}
#main {
}
#footer {
width:870px:
}
Common.css:
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
}
a {
text-decoration:none;
}
Testing it with Firebug, I see #header is 870px, but #menu is bigger that #header.
I have disabled margin and padding from menu style, with the same result.
Why #menu is bigger that 870px?
I want that border lines have 870px length.
Because
#menuwhich is contained inside it haswidthof 870 pixelspadding-leftof 34 pixelsthis adds to 870 + 34 = 904 pixels.
setting width of the
#menuelement to 870 – 34 = 836 pixels (width:836px;) will make it fit exactly..