css layout response

Method One: Using meta tags

<meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1">

Paste the complete code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1">
    <title>Document</title>
    <style>
        body {
            background: #abcdef;
        }
    </style>
</head>
<body>
    
</body>
</html>
View Code

Method 2: rem, with media queries

Paste the complete code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        body {
            background: #abcdef;
        }
        @media screen and (max-width: 1024px) {
            html {
                font-size: 20px;
            }
        }
        @media screen and (max-width: 768px) {
            html {
                font-size: 16px;
            }
        }
        @media screen and (max-width: 375px) {
            html {
                font-size: 12px;
            }
        }
        @media screen and (max-width: 320px) {
            html {
                font-size: 10px;
            }
        }
        .main {
            font-size: 4rem;
            text-align: center;
        }
    </style > 
</ head > 
< body > 
    < div class = "main" > look at me responded! </ div > 
</ body > 
</ HTML >
View Code

Renderings:

 

Guess you like

Origin www.cnblogs.com/caoxueying2018/p/10939260.html