...

View Full Version : Unexpected gap between CSS header elements



Rezzie
09-07-2010, 03:57 PM
Moderators: Please let me know if you have any issues with this post; I am not trying to advertise for the business whose site it is (they only serve customers within a few miles of their office, so they have nothing to gain through this post).

I'm currently redesigning a website and have run into an issue with some elements in the header. The header contains a logo, some text and a navigation bar. Between the bottom of the logo and the top of the navigation bar there is a relatively thick gap, shown in this screenshot:

http://imgur.com/luYVv.png

I don't want the gap, I don't know where it's come from and I don't know how to get rid of it :(

I can reduce it down to a single pixel by setting the line-height property of the div containing the logo down to 0.0, but it seems hacky and still doesn't fix the issue.

The work-in-progress version can be viewed live here (http://sandbox.woodstockdesigns.co.uk/), if anyone with more HTML/CSS experience can identify any silly mistakes I've made and give me some hints, pointers or solutions :)
Thanks in advance.

EDIT:

I removed it by adding the following classes:

.logo img
{
vertical-align:bottom;
}

.openingtimes p {
margin:0;
}

SB65
09-07-2010, 04:18 PM
Most of the gap can be fixed by setting your image to display:block. Without this the browser is allowing space "below the line" for the tails of g,y etc.

This still leaves about a one pixel line which is caused by the .opening times div extending a little further down than it needs to. You can fix this by removing the bottom margin on the <p> in that div via:


.openingtimes p{margin-bottom:0}

The latter is easy to spot in Firebug (http://getfirebug.com).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum