4 replies [Last post]
chup
chup's picture
User offline. Last seen 1 year 38 weeks ago. Offline
newbie
Timezone: GMT+8
Joined: 2010-08-20
Posts: 3
Points: 4

Hi all,

This is the website im working on
http://blog.yaoming.sg/

It look ok in Firefox and Chrome
http://avantgarden.com.sg/download/css1.jpg

But when on IE, the alignment is kinda wrong
http://avantgarden.com.sg/download/css2.jpg

The black bar spacing is all wrong in IE, any idea where did i do it wrongly?

Here is the css i have so far

.post_Date {
  /* border: 1px solid #ff0000; */
 
  width: 580px;
 
  margin-top: 0px;
  margin-right: 0px;
  margin-left: 0px;
  margin-bottom: 0px;
 
}
 
.post_DateLeft {
  /* border: 1px solid #006cff;  */
 
  width: 100px;
  height: 20px;
  float: left; 
 
  margin-top: 0px;
  margin-right: 0px;
  margin-left: 0px;
  margin-bottom: 0px;
 
}
 
.post_DateLeft h4 {
  font-family: Verdana, Arial, Helvetica, sans-serif; 
  font-size: 12px;
  font-weight: normal;
  line-height: 100%;
 
  text-decoration:none;
  color: #6c6c6c;
 
  padding-bottom: 10px; 
  line-height: 20px;
}
 
 
 
.post_DateRight {
  /* border: 1px solid #00ff18; */
 
  width: 420px;
  height: 20px;
  float: right; 
  text-align: right;
 
 
  margin-top: 0px;
  margin-right: 10px;
  margin-left: 0px;
  margin-bottom: 0px;
}
 
 
 
.post_title {
  /*  border: 1px solid #fff000; */
 
  width: 570px;
  float: right;
  background-color: #000000;
 
  margin-top: 0px;
  margin-right: 0px;
  margin-left: 0px;
  margin-bottom: 0px;
 
  padding-top: 6px;
  padding-bottom: 3px;
  padding-left: 20px;
  padding-right: 10px;
 
}
 
 
 
.post_titleHolder {
  /* border: 1px solid #00fff6; */
 
  width: 580px;
 
  margin-top: 0px;
  margin-right: 0px;
  margin-left: 0px;
  margin-bottom: 80px;
 
}

Thanks
Yaoming

Stomme poes
Stomme poes's picture
User offline. Last seen 29 weeks 5 days ago. Offline
rank Elder
Elder
Timezone: GMT+2
Joined: 2008-02-04
Posts: 1854
Points: 378

Margin collapse?

I think you are getting margin-collapse in modern browsers and not in IE.

.post_titleHolder {
margin:0 0 80px;
width:580px;
}

If I'm right, you will know it if you add
padding-bottom: 1px;
to that titleHolder box. Adding padding removes collapse and the gap should become as large in modern browsers as in IE.

If this works, then you'll just reduce the 80px bottom margin to 40px, and keep the 1px padding so it's the same in all browsers.

If it doesn't work, let us know.

I'm no expert, but I fake one on teh Internets

chup
chup's picture
User offline. Last seen 1 year 38 weeks ago. Offline
newbie
Timezone: GMT+8
Joined: 2010-08-20
Posts: 3
Points: 4

Hi Stomme poes, i tried ur

Hi Stomme poes,

i tried ur advice, but unfortunately it doesn't seem to work Sad

Any idea why?

Thanks

Stomme poes
Stomme poes's picture
User offline. Last seen 29 weeks 5 days ago. Offline
rank Elder
Elder
Timezone: GMT+2
Joined: 2008-02-04
Posts: 1854
Points: 378

Hi

Sorry, I was a bit wrong... it is the margins, but I missed something first time.

Your post_titleHolder has a bottom margin of 80px, and inside it, everything is floated (except post_Date). You also have a set width on post_titleHolder.

What this means is, you've triggered Haslayout in IE6 and 7 (not IE8, Microsoft finally got rid of Haslayout). Setting a width in this case did it. When Haslayout is triggered on a box like post_titleHolder who's holding floats, it will let post_titleHolder "see" those floats, enclose them, and then the 80px margin starts after the bottom of the black post_title.

But in the modern browsers, you don't have anything telling post_titleHolder that it has floated children (this is normal! This is what the rules for CSS say should happen; IE is just doing it wrong). So because those boxes like post_titleHolder and post_Date can't "see" the floats inside them, they act as if they were empty. So for modern browsers, your 80px is starting at the TOP of post_titleHolder! (give post_titleHolder a red background colour and you'll see it either doesn't show up at all, or looks like a 1px tall line because of the padding we added). So it's not really as tall as you thought it was.

http://gtwebdev.com/workshop/floats/enclosing-floats.php explains what float enclosing is.

So in your case, you'll want to make the modern browsers also "see" those floats, by making post_titleHolder enclose them. Since you only have a set width and not a set height (a good thing!), you can probably use the declaration "overflow: hidden" on post_titleHolder. You're not trying to hide overflow, but any box who has to know where children are overflowing has to know where its floats are too, and that's what we want it to do: know where the floats are.

post_titleHolder {
overflow: hidden;
}

There are other ways to make boxes see their floats, but a lot of the time this is easy and works. You can't use overflow:hidden when you have the possibility of content getting cut off (it hides overflow, of course), so this isn't always the best way to do it, but it should work perfectly for you here.

With this, your 80px should look too big now in ALL browsers, and you can still change it to 40px then.

I'm no expert, but I fake one on teh Internets

chup
chup's picture
User offline. Last seen 1 year 38 weeks ago. Offline
newbie
Timezone: GMT+8
Joined: 2010-08-20
Posts: 3
Points: 4

Hi Stomme poes, Thanks for

Hi Stomme poes,

Thanks for the insight, with some tweak it seem to work ok now!

Thanks again!