Bootstrap 3 Apply CSS on Mobile View Only

前端 未结 3 1214
执笔经年
执笔经年 2020-12-24 11:59

I\' am using Bootstrap 3, In the mobile view I would like to apply some CSS to fix up some bugs on mobile view. I have looked to documentations and Google it. I\' am can\'t

相关标签:
3条回答
  • 2020-12-24 12:02

    You can use responsive display classes https://getbootstrap.com/docs/4.3/utilities/display/ in Bootstrap 4

    So for example, you want to hide a specific element for only phones (in both portrait & landscape mode or xs and sm), you can do

    <div class="big_image d-none d-md-block">
    </div>
    

    What it does is set display:none by default and makes it visible only from md and above.

    0 讨论(0)
  • 2020-12-24 12:12

    Just use the appropriate media queries in your CSS, eg

    @media (max-width: 767px) {
        /* CSS goes here */
    }
    

    Bootstrap defines the following widths

    • Extra small devices (phones, less than 768px)
    • Small devices (tablets, 768px and up)
    • Medium devices (desktops, 992px and up)
    • Large devices (large desktops, 1200px and up)

    See http://css-tricks.com/css-media-queries/ for some more information on media queries.

    0 讨论(0)
  • 2020-12-24 12:13

    There are also responsive utilities, you can add classes to certain elements to either show or hide them at certain viewport sizes.

    .hidden-xs or .visible-xs
    

    http://getbootstrap.com/css/#responsive-utilities

    0 讨论(0)
提交回复
热议问题