Home > Article > Web Front-end > What new units are added in css3
New units added in css3: 1. "ch", the width of character 0; 2. "rem", a relative unit, mainly relative to the size of the root element font; 3. "vw", the window Width; 4. "vh", window height; 5. "vmin"; 6. "vmax", etc.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
New length units in CSS3
The new length units in CSS3 are as follows,
ch
, the width of character 0
rem
, is a relative unit, mainly relative to the size of the root element font, To use rem, we need to refer to the specified root element.
vw
, viewpoint width, window width, 1vw=1% of the window width
vh
, viewpoint height, window height, 1vh=1% of the window height
vmin
, vmax
, etc.
The newly added viewpoint-related units are generally targeted at mobile devices.
rem
is actually the same thing as em
, except that rem
has an additional restriction, which represents the root element (html element) font-size. We can take a look at the difference between
rem
and em
through the following example,
<html style="font-size: 12px;"> <body> <div id="div1" style="font-size: 16px"> <div id="div2" style="font-size: 1.2em"></div> <div id="div3" style="font-size: 1.2rem"> <div id="div4" style="font-size: 1.2em"></div> </div> </div> </body> </html>
At this time,
font-size of div2: 16px*1.2em=19.2px
12px*1.2 rem=14.4px
12px*1.2rem*1.2em=17.28px
rem does not have a cascading relationship, but
em does.
rem units.
css video tutorial)
The above is the detailed content of What new units are added in css3. For more information, please follow other related articles on the PHP Chinese website!