Forum Moderators: not2easy

Message Too Old, No Replies

Background Problem in IE6

Div appears wider than set in IE6

         

Uriel

2:31 pm on May 13, 2005 (gmt 0)

10+ Year Member



Hi.

I wanted news meta description to appear in a block with curved edges. But the description is variable length, so I produced a top gif and a bottom gif. The top gif (upper curves)is a background image to the main div, below that is another empty div with bottom curved background img. So I have


<div class="newsstory">
<h3 class="newsstory">Headline</h3>
<p>blah blah blah</p></div>
<div class="storybutt"></div>

and the css


div.newsstory {
padding: 3px 3px 0px 5px;
background-image: url(../i/news_div_bg.gif);
background-repeat: no-repeat;
margin-bottom: 0px;
width: 350px;
background-color: #FFCC66;
}
div.storybutt {
background-image: url(../i/storybutt.gif);
background-repeat: no-repeat;
height: 6px;
margin-bottom: 4px;
}

Just in case the text is ever long enough to make the box bigger than the background images, I have made the div background color the same as the images. that's where the fun starts. Displays fine in Firefox, just as I intended. In IE6, you can see where the image ends and you get another 3 or 4 pixels of the div background to the right of it, ruining the whole thing.

Any suggestions? I am stumped.

encyclo

2:42 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com] Uriel.

It sounds like a box-model problem. What doctype (if any) are you using in your HTML?

Basically, the difference could be with the calculated width of 350px for the newsstory div: you have horizontal padding of 8px which can throw things out of kilter.

Uriel

3:06 pm on May 13, 2005 (gmt 0)

10+ Year Member



Hi there, and thanks.

xhtml 1.0 transitional.

You're quite right - I thought it must be a box model thing, but wasn't aware IE6 had a box model issue...The div is 350px wide, plus 8. The background image is 358 pixels wide. Remove the padding and it looks fine in IE6 (even though the image is wider!) - however it's now wrong in firefox, as the background image is actually wider than the div, which is logically what you would expect..seems IE stretches the div to fit the background img?

As this is for an intranet where we use only IE it's ok as it is..but..interesting..

Many thanks,

Tony

encyclo

3:25 pm on May 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you using an XML prolog? Something like
<?xml version="1.0" encoding="UTF-8"?>
? If so, you should remove it as it pushes IE6 into quirks mode and thus alters the box model.