使用媒介查询设置字体尺寸

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>rem and media queries</title>
    <meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <style>
        html {
            height: 100%;
            width: 100%;
            font-size: 20px;
        }
        
        .box {
            width: 5rem;
            height: 5rem;
            display: inline-block;
            margin-right: .5rem;
            margin-bottom: .5rem;
        }
        
        .blue-box {
            background-color: red;
        }
        
        .org-box {
            background-color: blue;
        }
        
        @media only screen and (max-width:300px) {
            html {
                font-size: 10px;
            }
        }
        
        @media only screen and (min-width:300px) and (max-width:650px) {
            html {
                font-size: 20px;
            }
        }
        
        @media only screen and (min-width:650px) and (max-width:900px) {
            html {
                font-size: 30px;
            }
        }
        
        @media only screen and (min-width:900px) {
            html {
                font-size: 40px;
            }
        }
    </style>
</head>

<body>
    <div class="bd">
        <div class="box blue-box"></div>
        <div class="box org-box"></div>
        <div class="box blue-box"></div>
        <div class="box org-box"></div>
        <div class="box blue-box"></div>
        <div class="box org-box"></div>
        <div class="box blue-box"></div>
        <div class="box org-box"></div>
        <div class="box blue-box"></div>
    </div>
</body>

</html>

  

 

rem and media queries

 
posted @ 2022-03-22 19:46  33的男孩  阅读(87)  评论(0)    收藏  举报