twitter-bootstrap - 媒体查询的问题

标签 twitter-bootstrap css twitter-bootstrap-3 media-queries

所以我正在使用 bootstrap 构建我的个人网站。目前,我正在努力使内容适合移动设备尺寸。

我的问题是我不太记得如何使用 queries 并且我正在做的事情在某个时候停止工作。

所以基本上我所做的是将移动 CSS 样式放入主 CSS,然后随着屏幕变大而改变它。

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

是否有更好的方法来执行此操作并且更有意义。

最佳答案

这里是你应该如何使用 media queries :

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

非移动优先方法使用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*/ 
    }

移动优先方法使用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*/ 
    }

这是一个很好的tutorial来自 W3.org

关于twitter-bootstrap - 媒体查询的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28016406/

相关文章:

html - ie 不支持 webkit 滚动条 css

javascript - 如何设置列的高度相等?

css - “negative” CSS 中的文本?

html - Bootstrap : order elements with the 'navbar-right' class

javascript - 如果通过 ajax 加载,如何在 Bootstrap 中打开模式?

javascript - 导航栏和 AJAX 加载

css - 如何将较短的 flex 内容拉到上面的行中

css - 在 Bootstrap 中使用不均匀偏移使内容居中

html - 仅在所有 Bootstrap 元素上使用方边

twitter-bootstrap - Bootstrap : Place one div next to two others