@media screen and (max-device-width:1600px)失效

本文探讨了CSS中媒体查询的顺序问题,特别是当多个@media规则应用于不同设备宽度时的表现。通过调整规则顺序解决了样式覆盖的问题。
@media screen and (max-device-width:1600px){
          img{max-width: 90%;height: 500px;}
          .swiper-slide>div{
            width: auto;
            height: 700px;
            font-size: 2ch;
            position: relative;
            bottom: 30px;
            margin:0px;
      }
    }
  

这段代码失效

原代码为

@media screen and (max-device-width:1600px){
          img{max-width: 90%;height: 500px;}
          .swiper-slide>div{
            width: auto;
            height: 700px;
            font-size: 2ch;
            position: relative;
            bottom: 30px;
            margin:0px;
      }
    }
    @media screen and (max-device-width:1920px){
      img{max-width: 1300px;height: 500px;}
      .swiper-slide>div{
        width: 1500px;
        height: 600px;
        font-size: 2ch;
        position: relative;
        bottom: 50px;
      }
    }

解决方法,将1920px的放到上面:

@media screen and (max-device-width:1920px){
      img{max-width: 1300px;height: 500px;}
      .swiper-slide>div{
        width: 1500px;
        height: 600px;
        font-size: 2ch;
        position: relative;
        bottom: 50px;
      }
    }
    @media screen and (max-device-width:1600px){
          img{max-width: 90%;height: 500px;}
          .swiper-slide>div{
            width: auto;
            height: 700px;
            font-size: 2ch;
            position: relative;
            bottom: 30px;
            margin:0px;
      }
    }

 

<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>验证码邮件 - PlayOL</title> <style> @media screen and (max-width: 768px) { body { padding: 0 !important; } div[style*="max-width: 775px"] { max-width: 100% !important; width: 100% !important; margin: 0 !important; } div[style*="padding: 80px"] { padding: 40px 20px !important; padding-bottom: 40px !important; } div[style*="margin-bottom: 48px"][style*="box-sizing: border-box"] { margin-bottom: 32px !important; } img[style*="width: 100px"] { width: 80px !important; height: 80px !important; } div[style*="margin-bottom: 36px"][style*="font-size: 36px"] { font-size: 28px !important; margin-bottom: 28px !important; height: auto !important; } div[style*="margin-bottom: 24px"][style*="font-size: 36px"][style*="color: #FFFFFF"] { font-size: 28px !important; margin-bottom: 20px !important; height: auto !important; } div[style*="margin-bottom: 80px"][style*="font-size: 14px"] { font-size: 12px !important; margin-bottom: 48px !important; height: auto !important; } div[style*="height: 80px"][style*="border-left"] { height: 60px !important; padding-left: 20px !important; } div[style*="padding: 60px"][style*="padding-left: 80px"] { padding: 30px 20px !important; } div[style*="margin-bottom: 50px"][style*="text-align: left"] { margin-bottom: 40px !important; } } @media screen and (max-width: 480px) { div[style*="max-width: 775px"] { width: 100% !important; } div[style*="padding: 80px"] { padding: 30px 15px !important; padding-bottom: 30px !important; } div[style*="margin-bottom: 48px"][style*="box-sizing: border-box"] { margin-bottom: 24px !important; } img[style*="width: 100px"] { width: 60px !important; height: 60px !important; } div[style*="margin-bottom: 36px"][style*="font-size: 36px"] { font-size: 24px !important; margin-bottom: 20px !important; height: auto !important; } div[style*="margin-bottom: 24px"][style*="font-size: 36px"][style*="color: #FFFFFF"] { font-size: 24px !important; margin-bottom: 16px !important; height: auto !important; } div[style*="margin-bottom: 80px"][style*="font-size: 14px"] { font-size: 11px !important; margin-bottom: 36px !important; height: auto !important; } div[style*="height: 80px"][style*="border-left"] { height: 50px !important; padding-left: 15px !important; } div[style*="padding: 60px"][style*="padding-left: 80px"] { padding: 20px 15px !important; } div[style*="margin-bottom: 50px"][style*="text-align: left"] { margin-bottom: 32px !important; } } </style> </head> <body style="margin: 0; padding: 20px; box-sizing: border-box; font-family: &#39;Noto Sans&#39;, &#39;PingFang SC&#39;, -apple-system, BlinkMacSystemFont, &#39;Segoe UI&#39;, Arial, sans-serif; background-color: #f5f5f5; line-height: 1.6;"> <div style="max-width: 775px; margin: 0 auto; background-color: #ffffff; overflow: hidden; box-sizing: border-box;"> <div style="background-color: #141414; padding: 80px; padding-bottom: 80px; color: #ffffff; box-sizing: border-box; position: relative;"> <div style="margin-bottom: 48px; box-sizing: border-box;"> <img src="https://test-static.playol.com/static/imgs/header.png" alt="PlayOL Logo" style="width: 100px; height: 100px; display: block; box-sizing: border-box;"> </div> <div style="font-size: 36px; font-weight: 600; margin-bottom: 36px; color: #BFBFBF; box-sizing: border-box; line-height: 1.362; height: 49px;"> xiong@playol.com, 您好! </div> <div style="font-size: 36px; font-weight: 600; margin-bottom: 36px; color: #FFFFFF; box-sizing: border-box; line-height: 1.362; height: 98px;"> 欢迎来到PlayOL,<br> 这是您的验证码 </div> <div style="font-size: 36px; font-weight: 600; margin-bottom: 24px; color: #FFFFFF; box-sizing: border-box; line-height: 1.362; height: 49px;"> 0792FC </div> <div style="font-size: 14px; font-weight: 400; color: #FFFFFF; text-align: left; line-height: 1.362; box-sizing: border-box; margin-bottom: 80px; height: 19px;"> 验证码有效期为5分钟,请勿将验证码透露给他人。如非本人操作,您可以忽略这封邮件。 </div> <div style="padding-left: 24px; border-left: 4px solid #FF1F1F; box-sizing: border-box; height: 80px; display: flex;flex-direction: column;justify-content: center;"> <div style="font-size: 14px; box-sizing: border-box;">祝您游戏愉快,</div> <div style="font-size: 14px; font-weight: 600; box-sizing: border-box;">PlayOL团队</div> </div> </div> <div style="background-color: #ffffff; padding: 60px; padding-left: 80px; padding-right: 80px; color: #000000; box-sizing: border-box;"> <div style="font-size: 14px; font-weight: 400; margin-bottom: 20px; text-align: left; box-sizing: border-box; line-height: 1.4; color: #000000;"> 这封电子邮件由系统自动生成,请勿回复。 </div> <div style="text-align: left; margin-bottom: 50px; box-sizing: border-box;"> <div style="font-size: 14px; font-weight: 400; margin-bottom: 5px; color: #000000; line-height: 1.4; box-sizing: border-box; font-family: &#39;PingFang SC&#39;, sans-serif;"> 游玩网址</div> <a href="https://playol.com" target="_blank" style="text-decoration: none; box-sizing: border-box; font-size: 18px; font-weight: 400; color: #000000; line-height: 1.4; font-family: &#39;PingFang SC&#39;, sans-serif;">https://playol.com</a> </div> <div style="display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; box-sizing: border-box;"> <div style="flex: 1; box-sizing: border-box;"> <div style="text-align: left; margin-bottom: 24px; box-sizing: border-box;"> <div style="display: inline-flex; align-items: center; gap: 10px; box-sizing: border-box;"> <img src="https://test-static.playol.com/static/imgs/logo.png" alt="PlayOL Logo" style="width: 160px; height: 48px; box-sizing: border-box;"> </div> </div> <div style="text-align: left; font-size: 12px; font-weight: 400; line-height: 1.4; box-sizing: border-box; color: #000000; font-family: &#39;PingFang SC&#39;, sans-serif;"> <div style="margin-bottom: 8px; box-sizing: border-box;"><span style="font-weight: 700;">© PalyOL Corporation. All Rights Reserved.</span></div> <div style="box-sizing: border-box;">保留所有权利。所有商标均为其在x国及其他国家/地区的各自持有者所有。</div> </div> </div> </div> </div> </div> </body> </html> 这种怎么改
最新发布
11-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值