媒体查询问题 [英] Problems with media queries

查看:40
本文介绍了媒体查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在使用引导程序来建立我的个人网站.目前,我正在尝试使内容适合移动设备的大小.

So I'm building my personal site using bootstrap. Currently I'm trying to make the content fit at the mobile sizes.

我的问题是我不太记得如何使用查询以及我的操作方式在某一时刻停止工作.

My problem is I can't quite remember how to use queries and the way I'm doing it stops working at a certain point.

所以基本上我正在做的是将移动CSS样式放入主CSS中,然后随着屏幕变大对其进行更改.

So basically what I'm doing is putting the mobile CSS style in the main CSS then altering it as the screen gets bigger.

但是由于某些原因,查询在 992px 之后停止工作.

But for some reason the queries stop working after 992px.

是否有更好的方法可以使工作更有意义.

Is there a better way to do this that will work and make more sense.

推荐答案

以下是您应如何使用媒体查询:

请记住使用您喜欢/需要的尺寸.以下仅用于演示目的.

Remember use the sizes you like/need. This below is just for demo purposes.

非移动优先方法,使用 最大宽度 :

Non-Mobile First Method using max-width:

/*==========  Non-Mobile First Method  ==========*/

    @media only screen and (max-width: 960px) {
      /*your CSS Rules*/     
    }
    @media only screen and (max-width: 768px) {
      /*your CSS Rules*/     
    }
    @media only screen and (max-width: 640px) {
      /*your CSS Rules*/     
    }
    @media only screen and (max-width: 480px) {
      /*your CSS Rules*/     
    }       
    @media only screen and (max-width: 320px) {
      /*your CSS Rules*/ 
    }

移动优先方法,使用 最小宽度 :

Mobile First Method using min-width:

/*==========  Mobile First Method  ==========*/

    @media only screen and (min-width: 320px) {
      /*your CSS Rules*/     
    }
    @media only screen and (min-width: 480px) {
      /*your CSS Rules*/     
    }
    @media only screen and (min-width: 640px) {
      /*your CSS Rules*/     
    }
    @media only screen and (min-width: 768px) {
      /*your CSS Rules*/     
    }       
    @media only screen and (min-width: 960px) {
      /*your CSS Rules*/ 
    }

这是一个很好的教程,W3.org

Here is a good tutorial from W3.org

这篇关于媒体查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆