Forum Moderators: not2easy

Message Too Old, No Replies

IE 6 some how expands div.

Div expands in IE but not other browsers

         

erdy

10:47 pm on Jan 25, 2007 (gmt 0)

10+ Year Member



Hello,

I have a problem with a fixed size div expanding in IE 6 and below.
The div is centered with a fixed width.I know divs expand in IE to fit their content but the child div is seen as being the actual correct width, with the parent going beyond this by about 12px so basically something else is stretching the parent. It may help to know that the child div has a nav bar in it that is made up from a list with the a elements floated.
Anyway in short the basic problem is that the parent div is being stretched by something in IE 6 and below but in no other browsers.

Below is some HTML and CSS. Sorry I can't make this sound more simple.

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title>Our Site</title>

<link rel="stylesheet" type="text/css" href="elite_css.css"/>

</head>
<body id="home">

<div id="wrap1">
<div id="wrap2">
<div id="wrap3">

<div id="header">

<img src="images/elite_header.jpg" alt="Header" />

</div><!--Header-->

<div id="nav_bar">

<ul>

<li><a href="http://www.google.co.uk">Home</a></li>
<li><a href="http://www.google.co.uk">Services</a></li>
<li><a href="http://www.google.co.uk">Commercial</a></li>
<li><a href="http://www.google.co.uk">Pests</a></li>
<li id="righty"><a href="http://www.google.co.uk">Contact Us</a></li>

</ul>

<div id="clear_trap"></div><!--Clear Trap-->

</div><!--nav_bar-->

<div id="content">

<h3>Our Site</h3>

<p>Our company was established in 1996 etc......
</p>
<p>

Feel free to browse our site and
find out more about our
range of innovative and enviromenatly
conscientious services.
</p>

</div><!--content-->

<div id="van_container">

<img src="images/van.jpg" alt="Elite Pest Control" />

</div><!--van_container-->

</div><!--wrap3-->
</div><!--wrap2-->
</div><!--wrap1-->

<div id="footer">
<p>Footer</p>
</div><!--Footer-->

</body>

</html>

CSS

body{
background: #5f80c5 url(images/back_grad.jpg) 0 0 repeat-x;
text-align: center;
font-family: tahoma, helvetica, sans-serif;
margin: 0;
padding: 0;
}

#footer{
background: #5f80c5 url(images/footer.jpg) top center no-repeat;
width: 780px;
height: 26px;
margin: 0 auto;
padding: 2px 0;
font-size: .8em;
color: #fff;
/*border: 1px dashed white;*/
}

#wrap1{
background: #3446a2 url(images/header_shadow.jpg) left top no-repeat;
width: 780px;
margin: 0 auto;
/*border: 1px dashed red;*/
}

#wrap2{
background: url(images/right_shadow.jpg) right top no-repeat;
width: 780px;
margin: 0;
/*border: 2px solid green;*/
}

#wrap3{
background: url(images/left_shadow.jpg) left top no-repeat;
color: #fff;
width: 780px;
padding: 10px 0 0 0;
height: 595px;
margin: 0;
border: 1px dashed white;
text-align: left;
}

h3{
color: #d1cd6e;
}

#header {
margin-left: 10px;
/*border: 1px dashed green;*/
}

#header img {
display: block;
/*border: 1px solid red;*/
}

#nav_bar {
line-height: 24px;
width: 627px;
text-align: center;
margin: 0 10px 0 10px;
padding: 0 0 0 133px;
/*border: 1px solid yellow;*/
color: #fff;
background: #17204e url(images/nav_back.jpg) left center repeat-x;
}

ul{
margin: 0;
padding: 0;
width: 100%;
}

ul li{
list-style-type: none;
/*border: 1px dashed green;*/
display: inline;
float: left;
}

ul li a {
text-decoration: none;
color: #fff;
display: block;
/*border: 1px solid pink;*/
width: 8em;
font-size: 75%;
font-weight: 700;
border-left: 1px solid #17204e;/*TESTER*/
}

ul li a:hover {
background: url(images/nav_back_hover.jpg) left center repeat-x;
}

#righty{
border-right: 1px solid #17204e;
}

#clear_trap {
clear: both;
}

#van_container {
float: right;
display: inline;
border: 1px dashed white;
margin: 30px 10px 0 0;
}

#content {
margin-left: 10px;
padding: 0 0 0 1em;
border: 1px dashed green;
font-size: 78%;
line-height: 1.5em;
width: 43%;
display: inline;
float: left;
}

*****************

Sorry about so much code but unfortunately I don't have a clue which part of this is causing the problem so I had to include it all.

Thanks

Erdy.

mep00

2:23 am on Jan 26, 2007 (gmt 0)

10+ Year Member



I tested the code you posted in both IE and Firefox, and I saw no significant difference. The only changes I made were substituting the images and changing the <link /> to a style block, but neither should make a difference. If I threw it into quirks mode I saw a difference, but not the problem you described (the nav bar got shorter). The only other difference is that I'm running Linux, not Windows, but I don't think that change should make a difference, either.

erdy

4:45 pm on Jan 26, 2007 (gmt 0)

10+ Year Member



Thanks for looking through all of that code mep00. Do you think it could be then that one or more of my images are causing it to break?

I've sorted out the problem using the!important hack but it would just be nice to know why it happened.

cmarshall

4:58 pm on Jan 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Aw jeesh. I HATE using
!important
. I have been forced to use it every now and then, but I consider every
!important
in my CSS file to be a big fat *** FAILURE *** flag.

I try like heck to avoid hacks and

!important
declarations.

Nevertheless, I have had to use it occasionally.

<hangs head in shame, and shuffles off, Stage Left>