1. 程式人生 > >px-em-rem單位轉換

px-em-rem單位轉換

char back col har cnblogs itl ext utf-8 doc

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>px-em-rem</title>
        <style type="text/css">
        html{
            font-size: 15px;
        }
        body{
            font-size: 20px;
        }
            .px{
                width
: 100px; height: 100px; background: yellow; } .em{ width: 100em; /*1em = 16px; 參照是父元素*/ height: 100em; background: red; } .rem{ width: 100rem; /*1rem = 16px; 參照是根元素*/
height: 100rem; background: blue; /*0.4*font-size=40px; font-size=100px; 0.4*font-size=50px; font-size=125px; * */ } .father{ font-size: 12px; } </
style> </head> <body> <div class="px"></div> <div class="father"> <div class="em"></div> </div> <div class="rem"></div> </body> </html>

px-em-rem單位轉換