Stefan Bach: height && width für Grafiken mit "em", ist das toll?

Beitrag lesen

Hallo,

Nun habe ich mir gedacht, man könnte da ja mla die tolle Einheit "em"  nehmen.

Problem: Wie rechnet man px in em um?
Geht das überhaupt? weil px ja absolut und em relativ ist?

Nein, geht nicht wirklich. Zur Erklärung von em siehe:

http://www.w3.org/TR/REC-CSS2/syndata.html#length-units
-------------------------------------------------------

The 'em' unit is equal to the computed value of the 'font-size' property of the element on which it is used. The exception is when 'em' occurs in the value of the 'font-size' property itself, in which case it refers to the font size of the parent element. It may be used for vertical or horizontal measurement. (This unit is also sometimes called the quad-width in typographic texts.)

The 'ex' unit is defined by the font's 'x-height'. The x-height is so called because it is often equal to the height of the lowercase "x". However, an 'ex' is defined even for fonts that don't contain an "x".

Example(s):

The rule:

H1 { line-height: 1.2em }

means that the line height of H1 elements will be 20% greater than the font size of the H1 elements. On the other hand:

H1 { font-size: 1.2em }

means that the font-size of H1 elements will be 20% greater than the font size inherited by H1 elements.

When specified for the root of the document tree (e.g., "HTML" in HTML), 'em' and 'ex' refer to the property's initial value.

Die Höhe eines "em"s hängt also von der Schriftgröße ab. Und die Schriftgröße selbst hängt wenn sie selbst nur relativ angegeben wurde mit der Schriftart zusammen. Wie das aber alles verknüpft ist hat sich mir bis heute noch nicht erschlossen.

Viele Grüße,

Stefan

--
Lass dir das Tanzen NICHT verbieten
http://tanzverbot.de