The 100% width HTML element problem

Posted by Xeoncross on Stack Overflow See other posts from Stack Overflow or by Xeoncross
Published on 2011-01-11T02:48:11Z Indexed on 2011/01/11 2:53 UTC
Read the original article Hit count: 185

Filed under:
|
|

When assigning some HTML elements (like a form input) 100% width - you can no longer apply any additional styles that might effect the width. Things like border or padding will cause the element to exceed 100%. This results in awkward elements that may be outside of their parent elements.

Since CSS doesn't support width: 100% - 2px; The only way I know around this is to use an absolute pixel width (width: 98px) or chop the element off at 100% which is not really an option.

<div style="overflow:hidden;">
<input style="width:100%; border: 1px solid #000;" />
</div>

Are they're any other ways around this?

© Stack Overflow or respective owner

Related posts about html

Related posts about css