Forum Moderators: not2easy

Message Too Old, No Replies

What IE bug is this?

Bottom padding causes background to escape container

         

Fotiman

4:35 pm on Apr 4, 2006 (gmt 0)

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



I can't seem to figure out which IE bug this is, and how to fix it. The problem is that if the inner container has ANY bottom padding, then the background of the outermost container seems to extend out the bottom and into other elements below it. 2 requirements:

1. There must be at least 1 item below this in the markup
2. The inner div must have any bottom padding

Here's a code example:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset:utf-8">
<title></title>
<style type="text/css">
.shortcuts
{
background: #ccc;
margin: 0;
padding: 0;
}
.shortcuts h4
{
margin: 0;
border-bottom: 1px solid #fff;
padding: 0 0 0 5px;
}
.shortcuts h4 span
{
padding-right: 5px;
}
.shortcuts div.section
{
background: #eee;
margin: 0;
padding: 0;
}
.shortcuts div.wrapper
{
margin:0;
padding: 0;
padding-bottom: 1px; /* ANY BOTTOM PADDING TRIGGERS THE BUG */
}
</style>
</head>
<body>
<div class="shortcuts" id="adminshortcuts">
<h4><span>Administration Shortcuts</span></h4>
<div class="section">
<div class="wrapper">
Test
</div>
</div>
</div>
X <!-- Deleting me cures the bug... why? -->
</body>
</html>

SuzyUK

9:14 pm on Apr 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can't seem to figure out which IE bug this is, and how to fix it.

I can't figure out if it has been "named" yet ;) but it is an IE hasLayout [webmasterworld.com] error. (and I don't think it is a specific bug as it has *not* been fixed in IE7)

It also occurs with border and if there is only one div nested and there is an HTML comment! don't ask me why heh :o

here's minimum markup I got it triggered with

<body>
<div class="box">X<div class="wrapper">Test</div><!----></div>
X<!-- Delete me -->
</body>

CSS:
.box {
background: #fcf; /* this background stretches */
}

.wrapper {
background: #cfc;
border: 1px solid #000;
/* border-bottom: 0; */ /* uncomment to test border too */
}

Fix = set hasLayout == true on the

.wrapper
div
e.g.
.wrapper {zoom: 1;}

width: 100%;
would do too if there was no side padding or borders involved

Strange one!

Suzy

Fotiman

9:25 pm on Apr 4, 2006 (gmt 0)

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



Thanks Suzy. Kinda scary that this isn't fixed in IE7. :-/

Allan Rasmussen

12:46 pm on Apr 5, 2006 (gmt 0)

10+ Year Member



The most common way of triggering hasLayout is to apply height:1%;. The zoom property is of course likely to be even more preferable, but is not valid though...

Microsoft has explained why it's problematic to just enable hasLayout pr. default in an article [msdn.microsoft.com]. IE is ages behind when it comes to CSS and rendering, even in v.7...