I am learning CSS formatting absolutely positioned <input>. I would like it to “stretch” inside its container (which is also positioned “absolute”), so that it leaves, for example, 30 pixels both left and right, and fills all the space inside ...
I already found a sample on w3.org that uses both left and right to create some kind of “frame set” in CSS.
I also read an article from A-List-Apart about this technique, and I found here a few other questions regarding similar problems, but none of them relate to the specific problem that I will cover. I also found that I can wrap the inside <input>with help <div>, but I would like to work on this issue a bit to understand why this is wrong ...
Here is a working sample that I made to test and clarify the idea. In short, it's that simple:
<div id="sidebar">
<input type="text" value="input" />
</div>
with the following style:
body { height: 100% }
#sidebar {
position: absolute;
top: 0;
height: 100%;
left: 0;
width: 160px;
}
#sidebar input {
position: absolute;
margin: 0;
padding: 0;
height: 21px;
left: 30px;
right: 30px;
width: auto;
}
An interesting point is the last three lines, when I set left and right and leave the width as “auto”.
, , Chrome (v.26), FF.20 IE.10 : <input> div.. , : 100% ...
, DIV SPAN .
? , <input> : 100% <div>, ?
, - .
PS: "", html5-, , IE8 .