Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It doesn't work because a <code>span</code> is an <code>inline</code> element by default. Change it to an <code>inline-block</code> level element if you want to change the width of it. <a href="http://jsfiddle.net/JoshC/eaLTr/" rel="nofollow noreferrer"><strong>(example here)</strong></a></p> <pre><code>.bar span { padding:0; margin:0; height:100%; color:white; text-align:center; background-color:red; border:1px solid red; display:inline-block; /* Added this.. */ } </code></pre> <p>An <code>inline</code> element's dimensions are defined by the "<em>rendered content within them</em>" - this explains the behavior you are seeing. To achieve the desired results, you would need to use a block level element, as it doesn't exhibit this behavior.</p> <blockquote> <p>This [width] property does not apply to non-replaced inline elements. The content width of a non-replaced inline element's boxes is that of the <strong>rendered content within them</strong> (before any relative offset of children). Recall that inline boxes flow into line boxes. The width of line boxes is given by the their containing block, but may be shorted by the presence of floats. <a href="http://www.w3.org/TR/CSS2/visudet.html#the-width-property" rel="nofollow noreferrer"><strong>- W3 reference</strong></a></p> </blockquote> <p>Related to <a href="https://stackoverflow.com/questions/19920253/why-can-input-element-be-sized-if-they-are-inline-elements/19920304#19920304">this answer</a> I wrote a while back.</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