A workaround for a problem you might not know you have...yet

This is a discussion on "A workaround for a problem you might not know you have...yet" within the Web Page Design section. This forum, and the thread "A workaround for a problem you might not know you have...yet are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jul 13th, 2007, 17:52
Junior Member
Join Date: Jul 2007
Location: Dallas, TX
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Smile A workaround for a problem you might not know you have...yet

IE7 has been released and is gaining popularity. And like all things from Microsoft, there is both good news and bad news about its release.
The good news is that IE7 behaves much more like standards compliant browsers (like Firefox and Safari) in the way it renders CSS and HTML than earlier versions did. The bad news is (and I know this is going to seem shocking) that it's still a little buggy.

One of the bugs I recently encountered was the way that IE7 handles what I call a 'Clearing Div'.

One way that I use a 'clearing div' is when I have a 2 column CSS layout with a background image in my wrapper/container div that also has a floated element (like a left side navigation). The clearing div clears the elements inside the wrapper/container div and acts to 'pull down' the contents of the page and show the background image sort of like pulling down a window shade.

Example:
Code: Select all
<div id="wrapperHasABackgroundImage">
<div id="navFloatsLeft">
Some Links Here
</div>
<div id="pageContent">
Hello World, etc.
</div>
<div style="clear:both;"></div>
<div id="footer">
Footer Info
</div>
</div>
Firefox, Safari, Opera and even IE5.5 and IE6 allow the 'clearing div' to be empty, but for some unknown reason IE7 does not.
This can result in problems. For example, the page content can run past and over the footer content or the background image doesn't get fully displayed, etc.

IE7 wants either 'something' (like an '&nbsp;' or '<br />') in the div, or it wants a height specified. Both of which can impact the layout.
I came up with a very simple solution by simply setting the height of the clearing div to 1px and then setting a negative top margin of 1px resulting in a clearing div with no height. IE7 will then allows the clearing div to be empty.

Example Code:
Code: Select all
<div id="wrapperHasABackgroundImage">
<div id="navFloatsLeft">
Some Links Here
</div>
<div id="pageContent">
Hello World, etc.
</div>
<div class="clearingDiv;"></div>
<div id="footer">
Footer Info
</div>
</div>
Example CSS:
Code: Select all
.clearingDiv
{
height:1px;
margin-top:-1px;
clear:both;
}
Voila! Easy Cheesy!

Last edited by karinne; Jul 13th, 2007 at 18:01. Reason: Please use [code]...[/code] tags when displaying code! Just makes it easier to read.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Jul 13th, 2007, 18:00
Elite Veteran
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: A workaround for a problem you might not know you have...yet

Hmmm ... I've been using the overflow: hidden; method lately and I like it much more.

http://www.quirksmode.org/css/clearing.html

For some reason ... don't ask me why ... maybe it's 'cause we're Friday the 13th today but this code

Code: Select all
 .clearingDiv
{
height:1px;
margin-top:-1px;
clear:both;
}
just looks like an awful hack to me

But hey ... it's another method and it works.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
css, tips, work around, workaround

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
First image problem and inline list problem konnor5092 Web Page Design 8 Dec 1st, 2007 09:08
workaround for includes? alexgeek PHP Forum 4 Sep 15th, 2007 11:27
IE workaround? jwalker80 Web Page Design 1 Jul 12th, 2007 16:44


All times are GMT. The time now is 21:31.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42