startbootstrap-sb-admin-2 icon indicating copy to clipboard operation
startbootstrap-sb-admin-2 copied to clipboard

Hide sidebar on xs by default

Open divan opened this issue 5 years ago • 8 comments

Currently SBAdmin2 page shows sidebar by default when opened on the mobile device. It takes a good share of scarce screen width, and for my use case I would love to hide it on mobile. Is there an easy way to achieve it?

As I understand the solution is to add toggled class to sidebar only when opened on the small screen size.

divan avatar Nov 02 '19 18:11 divan

Ended up modifying sb-admin-2.js with following code:

if ($(window).width() < 768) {
  $(“.sidebar”).addClass(“toggled”)
}

but maybe there is a more “idiomatic” solution?

divan avatar Nov 02 '19 23:11 divan

I had same solution, but it "jumps" in the beginnig.

pinq- avatar Jan 17 '20 10:01 pinq-

I'll be doing some thinking about the side nav implementation in the next build!

davidtmiller avatar Jun 19 '20 19:06 davidtmiller

reverse .sidebar.toggled rules

@media (max-width:768px) {
    .sidebar {
        width: 0 !important;
        overflow: hidden;
    }

    .sidebar.toggled {
        width: auto !important;
    }
}

ewwink avatar Sep 30 '22 20:09 ewwink

您好,您的邮件我已经收到,我会尽快回复!  谢谢!

ccccgw avatar Sep 30 '22 20:09 ccccgw

I found a better solution to that, Just add this codes in your js file:

if ($(window).width() < 768) { $(".sidebar").addClass("toggled"); $(".nav-link").addClass("collapsed"); $("#collapseUtilities").removeClass("show"); }

FamiAbz avatar Jan 16 '23 12:01 FamiAbz

I found a better solution to that, Just add this codes in your js file:

if ($(window).width() < 768) { $(".sidebar").addClass("toggled"); $(".nav-link").addClass("collapsed"); $("#collapseUtilities").removeClass("show"); }

Thanks, working in 2023

AnnBonador avatar Feb 20 '23 10:02 AnnBonador

您好,您的邮件我已经收到,我会尽快回复!  谢谢!

ccccgw avatar Feb 20 '23 10:02 ccccgw