css - Bootstrap3 : mobile first approach, 阻止 xs 规则应用于更大的屏幕尺寸

标签 css twitter-bootstrap

我使用 Bootstrap 3.3 并使用移动优先方法进行创作。这是 css:

       .link{
            display: block;
            margin: 7px auto;
            text-align: center;

            /*Tablets+ only*/
            @media(min-width: 768px){
                float: right;
                position: relative;
                top: 10px;  }

在上面,除了一些附加属性之外,移动设备 (xs) 尺寸的属性也将应用于平板电脑 + 尺寸。编写上述内容的最佳方式是什么,这样手机的属性就不会应用于平板电脑+尺寸?

最佳答案

除了 css 代码,我们还需要您应用类的 html 的标记。
但是对于一般规则,您可以为不同的大小设置多个类,例如:

<div class="col-xs-12 col-sm-6 col-lg-3">
    some content...
</div>

这将适用:

  • col-12 xs 尺寸
  • col-6 sm 尺寸
  • col-3lg 尺寸
  • 等等...

关于文档的更多信息:

关于css - Bootstrap3 : mobile first approach, 阻止 xs 规则应用于更大的屏幕尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42716711/

相关文章:

html - Gmail登录页面div.card.signin-card.clearfix的CSS代码

javascript - 如何显示隐藏的 DIV 并在打开其他 div 时自动隐藏它

javascript - 加载时CSS淡入背景图像

HTML/CSS 样式标签不起作用

javascript - 强制启动选项卡处于事件状态

c# - Bootstrap Tabdrop 在 MVC cshtml 中不起作用

javascript - 有时网站前端的变化不会反射(reflect)在浏览器中并加载旧版本的网站

javascript - 为什么我的下拉菜单在 div 中不起作用?

html - Bootstrap 中的垂直对齐

css - 如何对齐 Bootstrap 表单输入