Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Check out what I came up with, a solution using the relatively unknown <code>box-sizing:border-box</code> style from CSS&nbsp;3. This allows a 'true' 100% width on any element regardless of that elements' padding and/or borders.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8"&gt; &lt;title&gt;Cross-browser CSS box-sizing:border-box&lt;/title&gt; &lt;style type="text/css"&gt; form {display:block; margin:0; padding:0; width:50%; border:1px solid green; overflow:visible} div, input {display:block; border:1px solid red; padding:5px; width:100%; font:normal 12px Arial} /* The voodoo starts here */ .bb { box-sizing: border-box; /* CSS 3 rec */ -moz-box-sizing: border-box; /* Firefox 2 */ -ms-box-sizing: border-box; /* Internet Explorer 8 */ -webkit-box-sizing: border-box; /* Safari 3 */ -khtml-box-sizing: border-box; /* Konqueror */ } &lt;/style&gt; &lt;!-- The voodoo gets scary. Force Internet Explorer 6 and Internet Explorer 7 to support Internet Explorer 5's box model --&gt; &lt;!--[if lt IE 8]&gt;&lt;style&gt;.bb {behavior:url("boxsizing.htc");}&lt;/style&gt;&lt;![endif]--&gt; &lt;/head&gt; &lt;body&gt; &lt;form name="foo" action="#"&gt; &lt;div class="bb"&gt;div&lt;/div&gt; &lt;input class="bb" size="20" name="bar" value="field"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This solution supports Internet&nbsp;Explorer&nbsp;6 and Internet&nbsp;Explorer&nbsp;7 via a behaviour written by Erik Arvidsson with some tweaks from Dean Edwards to support percentage and other non-pixel widths.</p> <p><a href="http://www.test.dev.arc.net.au/width_auto.html" rel="noreferrer">Working example</a><br> <a href="http://www.test.dev.arc.net.au/boxsizing.htc" rel="noreferrer">Behaviour (boxsizing.htc)</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload