Jump to content

weird layout problems


donald7777

Recommended Posts

The left-layout anddcontent divs are about 10px below the header in Firefox even though none of them have any margins to cause this. It's because you have a ul tag at the top of you left-layout div and lots of elements like ul, ol, p, h1 to h6, input and a few others have default margins, in this case a top margin, so add this to your styles:-

ul { margin: 0; }

 

because the default margin causes the margin to be outside the div instead of inside, and sometimes this also happens if you have a p tag or a h1 tag with a large top margin and it pushes the div down so that the text is at the top of the div and the margin is outside. It's not always the same for all browsers. In your case IE7 showed no space because its default margin seems to be on the bottom of tags while Firefox's margins are on top.

 

I'm not surprised that you were confused by that. Many coders set all margins and padding to 0 first, then add back in specific places where they want it.

Edited by Wickham
Link to comment
Share on other sites

Your #.top-navbar has margin-top:-70px; which has moved it up away from its normal position into the gray header above and then the lower divs have moved up into the position where #top-navbar was.

 

Delete margin-top: -70px first which will get all lower divs into other positions, then think again.

 

You've got an awful lot of top, left, right and margin positions (some negative). It's best to delete all of them at first to let divs find their normal position, then move one or two with margins (if no position or position: relative) or top and left positions if position: absolute.

 

You could float: right #top-navbar inside the #header, but it needs coding first then the logo div shows in the remaining space on the left:-

 

.top-navbar { background-color: pink; float: right;

height: 20px;

/* left: 175px;*/

width: 340px;

margin-right: auto;

/*margin-left: 375px;*/

margin-top: 10px;/*-70px;*/

position:relative;

padding:0;

}

 

Markup:-

 

 

links go here

 

 

 

.......................

 

even after only doing the above edits, other things need sorting out, but it moves the nav into the right side of the header and the other divs show below without spaces or overlapping.

Edited by Wickham
Link to comment
Share on other sites

I played around a little bit - of course I don't exactly know what you have in mind for the final look, and the colors are mostly to show where stuff is. The main things I changes I made are:

 

  • Changed doctype to html strict
  • arranged CSS in order - it doesn't affect how it renders, but it makes it easier to work in and follow along.
  • added the * {margin: 0; padding;} and removed all the now redundant margin: 0;s from the rest
  • removed some unnecessary divs
  • added actual content instead of the height - content will likely not be the same across the site, so setting a fixed height easily leads to trouble

 

Mostly, I tried to streamline things. (And I didn't follow the entire discussion in this thread, I was busy playing with the page).

 

Oops - and here's my version: http://www.aandbwebdesign.com/misc/don77.html

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...