Quantcast
Channel: Collapse div/element on mobile screens only with Bootstrap - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by frontenddeveloper.0fees.net for Collapse div/element on mobile screens only with Bootstrap

$
0
0

I had the same problem using Bootstrap V3. I followed the tutorial on the official documentation, but couldn't get the sidebar to collapse by default on mobiles.

This comes from a bug in Bootstrap V3 source files (custom version generated on 2013/09/05). Just load the following CSS right after the original bootstrap.css :

.collapse{display:none}.collapse.in{display:block}.collapsing{position:relative;height:0;overflow:hidden;-webkit-transition:height .35s ease;transition:height .35s ease}@media screen and (min-width:768px){.nav-collapse.collapse{display:block!important;height:auto!important;overflow:visible!important}}

(Those styles come from a previous version of the original Bootstrap V3 source).

Otherwise, my only mistake was to initialize the collapse plug-in in my HTML page. So if you've got something like this in your HTML source code :

<script type="text/javascript">    $(document).ready(function(){        $('.collapse').collapse();    });</script>

...then just remove it and the collapse plug-in will work like a charm.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>