@media

本文介绍了CSS中的媒体查询如何应用于响应式设计,通过示例展示了如何根据屏幕宽度调整背景颜色,并在移动端隐藏某些字段。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

not :否定媒体查询,必须制定媒体类型

only

and :就是全部满足菜执行

,:有一个满足就成立,等价于or

如果文档宽度小于 300 像素则修改背景颜色(background-color):

@media screen and (max-width: 300px) {    body {
	       
	background-color:lightblue;    }}

 如果像素小于700,怎隐藏字段

<!-- 移动端 -->
<style scoped>
@media only screen and (max-width: 700px) {
    /* .clearfix::after{
        content: '';
        display: block;
        clear: both;
    } */
    .head-logo {
        width: 50px !important;
        height: 50px !important;
        margin-left: 30px !important;
    }
    .logo {
        display: block !important;
        width: 180px;
        height: 50px;
        float: right;
        margin-top: 10px !important;
        margin-right: 80px !important;
    }
    #student .list {
        display: block !important;
    }
    .list li:last-of-type {
        padding: 0 10px !important;
        margin: 0 10px !important;
    }
    .msg {
        z-index: 999;
    }
    .practice{
        display: none;
    }
}
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值