Today while developing a WordPress theme for a client, I ran into a vexing Internet Explorer 7 bug. Anyone who’s done any website design is familiar with Internet Explorer 6 (or earlier) wreaking havoc with standards-compliant work that looks good in, say, Firefox. But thankfully IE 7 has for the most part been a big improvement over its predecessor. That’s what made this bug so strange: it didn’t affect IE 6, just IE 7.
The first image shows a screenshot of the problem: the title of the post is drooping into the post. Usually when you see something like this, it means that the containing element has not been cleared. There are a number of ways to clear an element: a popular fix these days uses a pseudo class; the classic approach has been to put a cleared element within the same element as the floating element, but after it. Neither fix works for this bug.
Thankfully, I found a demonstration of a similar problem with IE 7. Apparently if the element containing the floating element has a set height or a maximum height, it confuses IE 7. According to the standard, a browser should obey the CSS height of the element (and IE 7 does—good job!—unlike IE 6). But every cleared element after the floater should be pushed down, not overlapped, by the floater.
The solution is to remove the height assignment from the container element, if you can. In my case, for another part of the site experiencing the same problem, I needed the element to have enough height to show a background image. The solution was to use the min-height property, which doesn’t trigger the bug.
The final image shows what it should look like, as rendered by Firefox.
20 Comments
thank you so much for this! i was doing a website, and i couldn’t figure out why everything was so screwy in IE7 when supposedly everything was supposed to be BETTER in IE7… got rid of the width, and everything lines up perfectly, in BOTH browsers!
Awesome… thanks so much for the help! Always nice when a friend provides a solution.
Thanks for the information, really helped. I’d not come across this before so could not figure out what was going wrong!
Good work.
Well, I had an issue like this. Two elements, both floated and one floated inside the other. Removing the height property did not help things though.I wonder if I am experiencing the same bug after all. Adding a clear property to either did not help either….
Thanks for the post! It helped me finding the problem. my last problem with browsers compatibility was with IE7, removing height did the trick.
Yeah I always avoid putting heights on my elements. If you add the clear float fix to all block level elements except for the footer and p element it should automate everything for you. Check out my article I wrote on it clear float
thanks so much for this, spent ages thinking I needed an updated version of the clearfix hack only to find I’d reused an element with a set height.
I wasn’t aware of that bug, so thank you, this saved the day.
A huge thank you for this. With one change from “height” to “min-height” my WordPress page was converted from a total mess in IE7 to a beautiful thing. This has saved me HOURS of work.
Well done! Thanks for sharing. And great job on your wordpress theme design.
That’s really more a problem with CSS. No browser in IE7′s time was able to support CSS5.
i need some help how i stop my banner form floating to the right?
@charset “utf-8″;
/* CSS Document */
:focus {
outline: 0;
}
body {
background: #222;
margin: 0; padding: 0;
font: normal 10px Verdana, Arial, Helvetica, sans-serif;
}
*{outline: none;}
img {border: 0;}
.container {
width: 790px;
padding: 0;
margin: 0 auto;
display:inline;
}
.folio_block {
position: absolute;
left: 50%; top: 50%;
margin: -140px 0 0 -395px;
display:inline;
}
/*–Main Container–*/
.main_view {
float: left;
position:relative;
display:inline;
}
/*–Window/Masking Styles–*/
.window {
height:210px;
width: 722px;
overflow: hidden; /*–Hides anything outside of the set width/height–*/
position: relative;
}
.image_reel {
position: absolute;
top: -1px;
left: 2px;
width: 3630px;
display:inline;
}
.image_reel img {
float:left;
display:inline-block;
}
/*–Paging Styles–*/
.paging {
position: absolute;
bottom: 40px; right: -7px;
width: 178px; height:47px;
z-index: 100; /*–Assures the paging stays on the top layer–*/
text-align: center;
line-height: 40px;
background: url(menu-banner/paging_bg2.png) no-repeat;
display: inline; /*–Hidden by default, will be later shown with jQuery–*/
}
.paging a {
padding: 3px;
text-decoration: none;
color: #fff;
}
.paging a.active {
font-weight: bold;
background: #fa5400;
border: 1px solid #04355a;
-moz-border-radius: 3px;
-khtml-border-radius: 3px;
-webkit-border-radius: 3px;
}
.floatbox {
float: left;
width: 500px;
height: 150px;
margin: 5px 0 5px 100px;
display: inline;
}
.paging a:hover {font-weight: bold;}
.item {
margin: 5px;
padding: 10px;
}
Thank you. I was trying to resolve that for hours
Fixed my ie7 float problem by adding a min-height property even though I did not have an explicit height set. Good stuff, thanks for the post.
my site works in every browser but IE 7. apparently IE 7 can’t handle my CSS. i’ve tried applying the fix discussed on this page but i’ve had no luck. i hope it’s okay if i post a link to the dev site ….
http://www.ribitgreen.com/beta/contact.html
any help would be appreciated
b
IE really has a lot of bugs and other browsing problems. Maybe Windows should make a way to minimize or eliminate these type of problems so users will never have to use other browser.
I really wana thank you for providing such informative and qualitative material so often and Your articles are very well written and unique.wireless satellite internet
Thank you for this! I spent a lot of time trying to figure this out until I read your post.
The solution was to use the min-height property, which doesn’t trigger the bug.
hey Filosofo,
Internet Explorer 7 is not movable type due to decoupling from the windows shell with the IE7 Internet Explorer Upgration can solve the problem.
23 Trackbacks
[...] a bit more documentation at this site [...]
[...] 0; padding: 0; float: left; background: url(img/image.png) no-repeat; } You can go over to Austin Matzo’s blog for more information on this [...]
[...] the original post: Internet Explorer 7 Float Bug – Austin Matzko’s Blog Tags: float-bug, troubleshooting, [...]
[...] in real life. And normal people are already married much before your agePowered by Yahoo! AnswersMark asks…how do i meet this girl in hotornot?!?There is this girl I want to meet or at least cont…">how do i meet this girl in hotornot?!?There is this girl I want to meet or at least contact on [...]
[...] Price: $ 69.99 Your Price: $ 42.00 Liliana Avalon asks, Microsoft has been showing way too many flaws in all it's recent updates, it's …sted comments/solutions, or post your own! TE has product matched the following [...]
[...] bring podcasting to the professional world, expanding the listener base even more," Franklin said.Peterborough, NH (PRWEB) June 7, 2006 Outdoor sports gear retailer Eastern Mountain Sports (EMS) has… Lawrence Ryan, an avid outdoor sportsman and member of the Screen Actors Guild, hosts the show.Pwop [...]
[...] Was Random That Was Random – Who Hates Microsoft?? Who thinks Internet Explorer 7 is the WORST web browser EVER…xt-align: center;">That Was Random Daily [...]
[...] how you can take benefits of SEO services look at advertising in London service site.Related Blogs Google Chrome performs faster as compared to other browser in the world . At least this is what the…regular users standpoint . Measurements of around 1.86 billion individuals have been collected on [...]
[...] Bar. All set. Yahoo Mail is another category and a separate question. Powered by Yahoo! Answers Paul asks… How do I remove sites (which appear more than once) from my 'favorites' toolbar? I hav…2>How do I remove sites (which appear more than once) from my 'favorites' toolbar? I have clicked [...]
[...] proxy server?yeh the question – - — – - loladmin answers:Internet optionsPowered by Yahoo! AnswersJenny asks…Hypothetically, If you use bittorrent through a proxy server can your ISP tell you're u…ically, If you use bittorrent through a proxy server can your ISP tell you're using it?My ISP [...]
[...] Localization Support Using our online tutorials, you can localize any of our themes within minutesBuilt on latest Gabfire framework, with LinePress, we wanted to harness the look and feel of an onli…into the LinePress back-end as any of our other newspaper themes.[button_round color="red" url=""] [...]
[...] phones which can not be unlocked and are not compatible with GSM networksPowered by Yahoo! AnswersThomas asks…is internet explorer 7 available for downloads on smartphones like HTC Mogul?sandwalke…/div>sandwalker answers:No, IE7 is not a mobile program, but there is better out there. Look into [...]
[...] information of how you can take benefits of SEO services look at advertising in London service site.In the current era of internet, Google Chrome browser is titled as the fastest browser over World Wi…is measured for the website to get loaded on the basis of broadband connections . Around 1.86 [...]
[...] Close all Enabling Cookies in Internet Explorer 7, 8 9 Open the Internet Browser Click Tools Internet Options…ling [...]
[...] always land in the Spam folder so look in there Have a good day. Jess
Powered by Yahoo! AnswersRichard asks…how do you draw on the screen when on blogtv?how do you do it tell me please i need t…/div>how do you draw on the screen when on blogtv?how do you do it tell me please i need to know how [...]
[...] the Explorer has been improved a lot and it offers better support for Cascading Style Sheets(CSS).Windows Internet Explorer 7 which is an innate feature of Windows Vista is the new version of the we…made with fresh and superior competence for web-search and usage of numerous sources of information [...]
[...] Firefox stole. Overall though Internet Explorer 7 is as well designed product from Microsoft.359 While most of you have most likely thought after sometime IE6 was just old, clunky, out of date …ts to be made in IE7. Internet Explorer 7's new features: RSS Reader – Stay up to date on the most [...]
[...] something like that for a new phone every 12 months on a STABLE account: )Powered by Yahoo! AnswersMandy asks…Now is a bad time to buy a new smartphone, right?It looks like each cell phone company … buy a new smartphone, right?It looks like each cell phone company is releasing at least one fast [...]
[...] [...]
[...] newer tablets, more money than it's worth, and has terrible battery life.)Powered by Yahoo! AnswersLisa asks…Is the Samsumg Galaxy Note coming out on Verizon in the US? If so, when?sandwalker answe…e US? If so, when?sandwalker answers:You can try here for latest versions of Samsumg Galaxy [...]
[...] http://www.muzu.tv/gb/newtonfaulkner/it-must-be-love-music-video/999463/Powered by Yahoo! AnswersRobert asks…Getting contacts from iCloud to my Samsung Galaxy S2?Basically I'm trying to get all t…2>Getting contacts from iCloud to my Samsung Galaxy S2?Basically I'm trying to get all the contacts [...]
[...] you can install more than antispywares to make sure your computer is safe.Powered by Yahoo! AnswersRobert asks…How do you block casino games from being played on your computer without canceling the…mes from being played on your computer without canceling the internet service?Jeny answers:First of [...]
[...] people around the world?Sella answers:Go here for real or play chip games.Powered by Yahoo! AnswersSteven asks…How do you block casino games from being played on your computer without canceling the…asino games from being played on your computer without canceling the internet service?Sella [...]