How to make a DIV inherit the value of "em" from the parent

We all know that the value of the elastic layout "em" for this object refers to the parent object, for example:

<div id="div1" style="font-size:1em;">
 <p>Hello</p>
 <div id="div2" style="font-size:0.5em;">
<p>Hello</p>
 <div id="div3" style="font-size:0.5em;">
  <p>Hello</p>
 </div>
</div>
 </div>

But is it possible to make the sub-value of the DIV "reset" it em or get its value from the parent above the chain?

Basically, I have some nested DIVs, and I want one of the internal ones to use the value of its own em document. Using 1em is not good, as one of the parents of the DIV already uses a fractional value.

Thanks in advance

Simon

+4
source share
2 answers

: , CSS.

rem em :

font-size .

" ".


, . , em, .

, , .

, # div2 0,5em, , # div3 , # div1, font-size: 2em

( width) , .

+5

, CSS , . , CSS-?

<div id="div1">
<p class="font1em">Hello</p>
<div id="div2">
<p class="fonthalfem">Hello</p>
<div id="div3">
<p class="fonthalfem">Hello</p>
</div>
</div>
</div> 
0

Source: https://habr.com/ru/post/1777339/


All Articles