This is a simplified version of my question earlier today since I didn’t get a satisfactory reply.
I have a HTML and CSS code as in this Fiddle: http://jsfiddle.net/wNGHz/
How can I make the <input> resize automatically when its parent frame is resized?
Notes:
- I prefer to use only CSS rather than JavaScript.
- The
<input>should have 100px distance from left and right edges of the parent.
Unfortunately, there is no better way. It has to do with the fact that
inputis a replaced element, which means it behaves differently to non-replaced elements such asdiv.One difference is that
position: absolute; left: 0; right: 0won’t work in the same way on aninputas it does ondiv(except in WebKit).The best workaround is to wrap the
inputin adiv:http://jsfiddle.net/thirtydot/wNGHz/6/
When you have
input { width: 100%; }, it’s usually a good idea to also addbox-sizing: border-box, to make anypaddingandborderon theinputbe counted inside thewidth: 100%: http://jsfiddle.net/thirtydot/wNGHz/7/