I have a float issue in IE6&ie7:
<!DOCTYPE html>
<html>
<head>
<title>lily</title>
<style>
div{width: 100px; height: 100px;}
.div1{background: red; float: left;}
.div2{background: yellow;}
</style>
</head>
<body>
<div class="div1">div1</div>
<div class="div2">div2</div>
</body>
</html>
why it displays different in IE6&&IE7 and Chrome? And how to solve it in ie6&ie7?
:
Your second
div
is clearing your first, but only the text. If you set a left margin you can tell it to sit next to the floated div.http://jsfiddle.net/Pjvtb/
Note: IE 6 and 7 incorrectly move the second
div
past the first one, due tohasLayout
. You can search online for more information about the problems associated with it. There is also a3px
"text jog" present in IE 6 (possibly 7 too, I can't remember) which usually meant, to display the same in all browsers, one would actually make themargin-left: 103px
to accommodate IE's weirdness.