Home  >  Article  >  Web Front-end  >  What new units are added in css3

What new units are added in css3

青灯夜游
青灯夜游Original
2022-01-12 17:17:072089browse

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.

What new units are added in css3

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

  • ##font-size of div3:

    12px*1.2 rem=14.4px

  • font-size of div4:

    12px*1.2rem*1.2em=17.28px

It can be seen that

rem does not have a cascading relationship, but em does.

It is worth noting that IE8 and below, Safari 4, IOS 3.2, etc. do not support

rem units.

(Learning video sharing:

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn