Forum Moderators: not2easy

Message Too Old, No Replies

shadows don't work in IE 6 Win XP

Win XP pushes content down

         

Lorel

10:45 pm on Oct 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm working on a page with a gradient background with a narrow vertical gradient border on each side of the page resembling a shadow behind the page. (I'm switching the page from 100% tables over to CSS).

The shadow consists of two images 8 pixels wide and 509 pixels high, (one floated left and one floated right), the lower ends of which fade into the gradient background color.

I put the left and right shadows inside a wrapper otherwise they moved to far left and right edges of the page. The wrapper is 16 pixels wider than the container so it will contain the two shaddow images. There is no padding or margins on these items so I'm not sure what's wrong. I tried increasing width of the wrapper but that didn't work either. I tried adding z-index:-1; but that didn't help so I don't think this is the cause (I'm aware that IE 6 has an z-index bug although I don't know how to fix it).

This displays correctly on all browsers on the Mac and Firefox on Win XP but not IE 6 Win XP where it forces the content below the images which are 509 pixels high.

Can anyone tell what the problem might be?

Here is the relevant code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<style type="text/css">

body {
margin: 0px;
background-color: #E5E5E5;
font-family: Tahoma;
font-weight:normal;
font-size: 12px;
color: #333333;
background-image:url(images/site-bg.gif);
background-position:top;
background-repeat:repeat-x; }

/*provides boundary for left and right shadows*/
div#wrapper {
width:778px;
margin-left:auto;
margin-right:auto; }

div#left {float:left;
width:8px;
height:509px;
z-index:-1;
background: url(images/lshad-grad.gif);
background-repeat: no-repeat; }

div#right { float:right;
width:8px;
height:509px;
z-index:-1;
background: url(images/rshad-grad.gif);
background-repeat: no-repeat; }

div#container {
width:760px;
border:1px solid #cccccc;
margin-left:auto;
margin-right:auto; }

</style>

</head>
<body>

<div id="wrapper">
<div id="left"> &nbsp; </div>
<div id="right"> &nbsp; </div>

<div id="container">

###########content goes here#######
<br>blah
<br>blah
<br>blah
<br>blah
<br>blah
<br>

</div>
</div>

</body>
</html>

swa66

12:56 am on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try removing all but the border from div#container.
IE6 calculates width of stuff in a different manner from the rest of the browsers.

alt131

8:28 am on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Personally I am always suspicious of margin:auto in ie6, and although your numbers seem to add up, it does look like ie6 is calculating the width of
div#container
so it becomes too wide.

Try changing

width:760px
in div#nav to
min-width:760px
- or max-width (your choice). As ie6 does not understand either it will calculate the width to fit "between" the borders.
[edit]grammar&spelling[/edit]

Lorel

6:34 pm on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The two above suggestions didn't work as they messed up the layout.

I've been playing around with the code and changed the width of wrapper to 784 and then the page loads correctly. However then there is a blank space between the left and right shadow images and the container edge. The container has a width of 760. If you count the border on each side of the container that only goes up to 762. Which means there are 22 pixels of space messing up this layout, i.e., 11 pixels on each side of the container.

I checked the CSS file and there is nothing with a margin or padding that would affect the width of the content/container/footer.

Any one know what could be causing this?

alt131

10:16 pm on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi lorel,
The two above suggestions didn't work as they messed up the layout.

Can you be more specific? - On the provided code use of mix/min-width stopped your div#container dropping in ie6&7, winSafari, Op9, ff2&3 as requested.

Any one know what could be causing this?

Per your numbers, you have 11px per "side". That's the 8px width of the floated elements, plus 3px which indicates the bugs explained by Dr Doc in Taking on IE bugs [webmasterworld.com], or in more detail at positioniseverything under "Explorer Exposed" linked from that post. However, more recent discussions/tests suggest there are really a much smaller list of bugs, although I can't immediately point to a thread here.

ie6 draws floats in a way that produces layout differences with other ua's, especially when mixing floats with non-floated elements, and setting a width on some, and not all of the elements. max/min-width worked on the provided code because it removed the specified width from non-floated div#container. On the provided code that was enough.

You might try any of the suggestions in the thread linked above in the code you are working with, however another way to is try to avoid "fixes" - and just try to avoid triggering the effect. One way to do that is to modify your html so div#right comes after after div#container in the source. Then set

float:left
on div#container to order it to float to the left of div#right (which is where you want it to be). You may need to set
clear:both
on div#footer if you have one (as your last post suggests) so it clears all the floated elements.

On the provided code that resolves the reported problem on the listed browsers without any other change to the posted code.

Another option is to remove the floats and set

position:relative
on div#wrapper, then set the other three divs to
position:absolute
with
top:0;
and:
div#left
left:0

div#container
left:8px

div#right
left:768px

BadBoyMcCoy

1:34 pm on Oct 8, 2008 (gmt 0)

10+ Year Member



The problem is that you have the margin-left and margin-right set to auto on the div#container when you dont need it. Just swap the margin auto for a float left and it works fine here. here is the code i used, I've added some background-colors so i could see what was goin on.

body {
margin: 0px;
background-color: #E5E5E5;
font-family: Tahoma;
font-weight:normal;
font-size: 12px;
color: #333333;
background-image:url(images/site-bg.gif);
background-position:top;
background-repeat:repeat-x; }

/*provides boundary for left and right shadows*/
div#wrapper {
width:778px;
margin-left:auto;
margin-right:auto;
background-color:#00FF00;
}

div#left {float:left;
width:8px;
height:509px;
background:#FF0000;
background-repeat: no-repeat; }

div#right { float:right;
width:8px;
height:509px;
background-repeat: no-repeat;
background-color:#FF0000;
}

div#container {
width:760px;
border:1px solid #cccccc;
float:left;
background-color:#FFFF00;
}

I think the problem was that the margin auto on both sides was pushing the 2 divs down

hope this works for you, tell me how u get

BadBoyMcCoy

1:37 pm on Oct 8, 2008 (gmt 0)

10+ Year Member



*hope this works for you, tell me how you get on

also I removed the z-index as I think this only works when you have element set with position:relative/auto/fixed etc...

Lorel

6:00 pm on Oct 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks for your tips BadBoy and Alt. I'll check out these ideas over the weekend and get back to you.