Consider the following code where you have a floated element (in this case a label
), followed by a div
with position: relative
, containing an input field with a width: 100%
.
<!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" xml:lang="en" lang="en">
<head>
<style type="text/css">
.label { float: left; }
.div { position: relative; }
.input { width: 100%; }
</style>
</head>
<body>
<label class="label">Label</label>
<div class="div">
<input class="input" type="text"/>
</div>
</body>
</html>
The issue is that on IE6, the input field doesn't show:
position: absolute
have layout, but elements with position: relative
don't necessarily have layout). My favorite way for doing so it to add a *zoom: 1
on the box, which will give you the expected result: