Bootstrap 3 only for mobile

后端 未结 3 788
余生分开走
余生分开走 2021-01-30 16:10

I have a site 1600px wide and I want to make that fit nicely on mobile only. How can I do with Bootstrap 3. I tried to use col-sm-*. but also effects o

3条回答
  •  情深已故
    2021-01-30 16:51

    You can create a jQuery function to unload Bootstrap CSS files at the size of 768px, and load it back when resized to lower width. This way you can design a mobile website without touching the desktop version, by using col-xs-* only

    function resize() {
    if ($(window).width() > 767) {
    $('link[rel=stylesheet][href~="bootstrap.min.css"]').prop('disabled', true);
    $('link[rel=stylesheet][href~="bootstrap-theme.min.css"]').prop('disabled', true);
    }   
    else {
    $('link[rel=stylesheet][href~="bootstrap.min.css"]').prop('disabled', false);
    $('link[rel=stylesheet][href~="bootstrap-theme.min.css"]').prop('disabled', false);
    }
    }
    

    and

    $(document).ready(function() {
    $(window).resize(resize);
    resize();   
    
    if ($(window).width() > 767) {
    $('link[rel=stylesheet][href~="bootstrap.min.css"]').prop('disabled', true);
    $('link[rel=stylesheet][href~="bootstrap-theme.min.css"]').prop('disabled', true);
    }
    });
    

提交回复
热议问题