【问题标题】:How to add margin between elements when alongside each other but not when stacked? [bootstrap]如何在元素之间添加边距,但不是堆叠时? [引导]
【发布时间】:2015-07-09 04:10:10
【问题描述】:

所以基本上我有 2 个按钮,我想在它们之间放置 20px 的空间。在移动设备上,虽然按钮是堆叠的并且它们偏离中心 20 像素。有人有想法么?我听说有人说使用 btn-toolbar 类,但它似乎不起作用..

【问题讨论】:

    标签: css twitter-bootstrap button margins


    【解决方案1】:

    在你的 CSS 文件的底部抛出这个媒体查询:

    @media screen and (max-width: 767px) {
        // declare CSS rules for your target buttons
    }
    

    【讨论】:

      【解决方案2】:

      只需添加一些自定义 CSS

      //Mobile First Responsive View full width Stacked Buttons
      .button-holder .btn{margin-right:0;width:100%;display:block;} 
      
      @media screen and (min-width: 480px){
        //Tablet/Desktop View left aligned buttons
        .button-holder .btn{width:auto;margin-right:20px;display:inline-block;}   
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-02-01
        • 1970-01-01
        • 2017-01-30
        • 1970-01-01
        • 1970-01-01
        • 2017-06-25
        • 1970-01-01
        • 2016-05-17
        相关资源
        最近更新 更多