Alan 0

My site looks fine in Safari and Firefox, but IE is giving me serious problems in versions 6, 7, and 8.

The site is divided into 3 content areas using divs: The main content area, and then two adjacent sidebars on the right of equal width. IE takes the first sidebar and pushes it underneath the furthest-right one, leaving a blank space in between.

The positioning is done with CSS, but I can't figure out what IE is doing to mess up the presentation.

Any pointers would be helpful.

Site: http://seriouslulz.com

2 answers

2
points

A quick look shows that both sidebars have a set width and are floated. This triggers float bugs in IE, including double margins etc, which can cause float drop.

The usual cure for IE's float bugs, when you need to float an element with a fixed width is to add display:inline; to it.

e.g.

try:

background-color: rgb(254, 254, 241);
float: left;
margin-left: -170px;
width: 165px;
display:inline;

for .side2

and

background-color: rgb(254, 254, 241);
float: left;
margin-left: -170px;
width: 165px;
display:inline;

for .side1

Answered over 7 years ago by Tony Crockford
  • First of all, thank you for your suggestion. I've added your code, but alas, IE still distorts the layout. I'm still trying to figure out the solution. Alan over 7 years ago
1
point

Here is some code that should create a 3 column layout that works in all browsers, with header and footer:

<style type="text/css"> 
body  {
    background: #666666;
    margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
    padding: 0;
    text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
    color: #000000;
}
#container { 
    position: relative; /* adding position: relative allows you to position the two sidebars relative to this container */
    width: 780px;  /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
    background: #FFFFFF;
    margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
    border: 1px solid #000000;
    text-align: left; /* this overrides the text-align: center on the body element. */
} 

#header { 
    height: 60px; /* if you're changing the source order of the columns, you'll may want to use a height on the header so that you can give the columns a predictable top value */
    background: #DDDDDD; 
    padding: 0 10px 0 20px;  /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */
} 
#sidebar1 {
    position: absolute;
    top: 60px;
    left: 0;
    width: 150px; /* the actual width of this div, in standards-compliant browsers, or standards mode in Internet Explorer will include the padding and border in addition to the width */
    background: #EBEBEB; /* the background color will be displayed for the length of the content in the column, but no further */
    padding: 15px 10px 15px 20px; /* padding keeps the content of the div away from the edges */
}
#sidebar2 {
    position: absolute;
    top: 60px;
    right: 0;
    width: 160px; /* the actual width of this div, in standards-compliant browsers, or standards mode in Internet Explorer will include the padding and border in addition to the width */
    background: #EBEBEB; /* the background color will be displayed for the length of the content in the column, but no further */
    padding: 15px 10px 15px 20px; /* padding keeps the content of the div away from the edges */
}
#mainContent { 
    margin: 0 200px; /* the right and left margins on this div element creates the two outer columns on the sides of the page. No matter how much content the sidebar divs contain, the column space will remain. */
    padding: 0 10px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}
#footer { 
    padding: 0 10px 0 20px; /* this padding matches the left alignment of the elements in the divs that appear above it. */
    background: #DDDDDD; 
}
</style>
</head>

<body>

<div id="container">
  <div id="header">header</div>
  <div id="sidebar1">left col</div>
  <div id="sidebar2">right col</div>
  <div id="mainContent">center col/content</div>
  <div id="footer">footer</div>
</div>
</body>
Answered over 7 years ago by Darryl Hein
  • Thank you for your template. If I cannot fix this bug in CSS, I'm probably going to recode the site so that it works in IE. Alan over 7 years ago