2023-07-29T09:47:48.png
screenshots.gif

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
<style>




div{
        /*元素宽度*/
        width:500px;

        /*元素高度*/
        height:500px;
        
    
    }



/*小于768px加载样式*/
@media screen and (max-width:768px){
    div{
        background-color: aqua;
    }
.p1{
    display:block;
}

.p2{
        display:none;
    }
.p3{
        display:none;
    }
}



/*设备大于768px并小于992px加载样式*/
@media screen and (min-width:768px) and (max-width:992px){
    div{
        background-color: chartreuse;
        
    }
    .p2{
        display:block;
    }


    .p1{
    display:none;
}

.p3{
        display:none;
    }
}




/*设备大于992px加载样式*/
@media screen  and (min-width:992px){
    div{
        background-color: orange;
    }
    .p3{
        display:block;
    }
    .p1{
    display:none;
}
    .p2{
    display:none;
}
}







</style>
</head>
<body>
    <div>
        <h1 class="p1">小于768px</h1>
        <h1 class="p2">大于768px并小于992px</h1>
        <h1 class="p3">大于992px</h1>


    </div>
</body>
</html>