Why are these two divs being pushed over so slightly to down?
My HTML is simple, I have a content area that wraps around everything and inside it I want three columsn. Two of them have to have fixed widths, and main content area should be flexible.
I wonder what I'm doing wrong - EDIT here is the complete code sorry if it's a bit long!:
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
<img src="../../Content/images/cumaviLogo.png" alt="Cumavi.com - Compras y ventas online en Bolivia!" />
<ul id="topuserbar">
<li>Bienvenidos, <span class="userSalute">Sergio!</span></li>
<li><a href="#">Mis Anuncios</a></li>
<li><a href="#">Perfil</a></li>
<li><a href="#">Ayuda</a><img class="helpicon" src="../../Content/images/helpIcon.png" alt="Help icon." width="20" height="20"/></li>
<li><a href="#">Cerrar Sesion</a></li>
</ul>
</div>
<div id="headershadow">
</div>
<div id="body">
<div id="leftnavigation"></div>
<div id="contentarea"></div>
<div id="advertisingarea">
</div>
</div>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</body>
</html>
body
{
background-image: url('images/test.png');
background-repeat:repeat;
margin:0;
padding:0;
}
#header
{
background-image: url('images/headerBackground.png');
background-repeat:repeat;
width:auto;
}
#headershadow
{
background-color:Black;
min-height:2px;
}
#topuserbar
{
font-family:Georgia;
font-size:large;
float:right;
margin-top:35px;
margin-right:15px;
}
#topuserbar ul
{
}
#topuserbar li
{
display:inline;
margin-left:10px;
color:#fff;
}
#topuserbar .helpicon
{
position:relative;开发者_如何转开发
top:4px;
left:2px;
}
#topuserbar a
{
color:White;
}
#topuserbar a:hover
{
color:Yellow;
}
/*****************BODY AREA*******************/
#body
{
border: 1px solid red;
min-height:800px;
width:960px;
}
#leftnavigation
{
border: 1px solid green;
min-height:500px;
float:left;
width:190px;
}
#contentarea
{
border:1px solid blue;
min-height:500px;
float:left;
width:590px;
}
#advertisingarea
{
border:1px solid orange;
width:150px;
float:left;
min-height:500px;
}
Could it be because of the cumulative 1 pixel border?
Sergio, I'm not sure if this is going to be the answer but try replacing borders with outlines. Borders have a pixel width whereas outlines don't. This may, possibly, solve your problem.
CSS usage: outline{1px solid red;}
Could it be:
#headershadow
{
background-color:Black;
min-height:2px;
The height and padding above/below the <ul id=topuserbar>
is pushing down the second and third divs.
Add height:43px;
(or greater) to #header to push elements below it down and that will line up the 3 body divs.
Firebug is your friend!
精彩评论