Reputation: 1483
I'm having a problem with floating divs and IE7. For example, the following HTML code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' lang='en' xml:lang='en'>
<head>
<title>IE Float Test</title>
<style>
.container {
width: 200px;
background: #ddd;
overflow: hidden;
}
.item {
float: left;
padding: 5px;
background: #eee;
margin: 5px;
}
</style>
</head>
<body>
<div class="container">
<div class="item">This is a item</div>
<div class="item">This is another item</div>
<div class="item">Last item</div>
</div>
</body>
</html>
Give's the following in chrome (plus other major browsers):
But, the following in IE7:
How do I get IE7 to move the item div to the next vertical position if it is too wide?
Many thanks, John.
Upvotes: 4
Views: 2641
Reputation: 9181
If you want the items stacked, there is no need to "float:left" in your ".item" CSS style. Block level elements like <div>
appear stacked by default.
Upvotes: 0
Reputation: 228162
Adding white-space: nowrap
to .item
works: http://jsbin.com/ifexuf/2
Is that acceptable?
Upvotes: 4