Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is no way to express that in CSS. </p> <blockquote> <p>The status text inherits its appearance from the global style sheet and does not know font size, family, line height, or anything.</p> </blockquote> <p>That's not quite correct. <em>Because</em> text in your status <code>div</code> inherits its values for <code>font-size</code>, <code>line-height</code>, etc. via the cascade, it "knows" these and will style itself accordingly. The problem is that CSS doesn't offer a way of using these values for calculations. They are only implicitly considered when declaring new properties.</p> <p>The only way to achieve exactly what you want is via JavaScript. I made a fiddle <a href="http://jsfiddle.net/kkoala/RXQuy/" rel="noreferrer">here</a> using some jQuery. In my example, a simple <code>body</code> declaration acts as the ancestor. Run it with different <code>font-size</code> and <code>line-height</code> values in the body CSS.</p> <p>In practice, I would combine this with your method as a fallback for scenarios where</p> <ol> <li>JavaScript is disabled</li> <li>the relevant ancestor's <code>line-height</code> is given as a percentage value (descendants inherit the <em>calculated</em> value) <em>and</em> you decide to change your status <code>font-size</code>. <strong>Example:</strong> The ancestor's <code>font-size</code> is <code>16px</code> and its <code>line-height</code> is <code>120%</code> (~ 19px). Now, if you decide your status needs more attention and declare <code>.progressStatus {font-size: 24px;}</code>, it will inherit the calculated <code>line-height</code> (still 19px). So you'd have a line-height smaller than the text size. Explicitly declaring a <code>line-height</code> as in your "half-solution" prevents that case from occuring.</li> </ol>
    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. 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