javascript - Make Bootstrap 3 collapsed menu overlay page - Stack Overflow

I was wondering if it's possible to make a Bootstrap collapsed menu show over the page rather than

I was wondering if it's possible to make a Bootstrap collapsed menu show over the page rather than pushing the page downward? I tried giving a z-index on the menu but with that, I had to make the menu use absolute positioning...bad idea. I want to stick with the route Bootstrap takes, but just make the menu overlay instead of push. Any ideas? Has anyone achieved this?

Thanks

I was wondering if it's possible to make a Bootstrap collapsed menu show over the page rather than pushing the page downward? I tried giving a z-index on the menu but with that, I had to make the menu use absolute positioning...bad idea. I want to stick with the route Bootstrap takes, but just make the menu overlay instead of push. Any ideas? Has anyone achieved this?

Thanks

Share Improve this question asked May 1, 2014 at 7:42 Martavis P.Martavis P. 1,8383 gold badges30 silver badges49 bronze badges 2
  • If you want it to overlay the other elements, you're going to have to use absolute positioning to take it out of the document flow, otherwise it'll just...push the other elements out of the way. – Olly Hodgson Commented May 1, 2014 at 8:05
  • Thanks. I am pleting it now. It's actually easier than I thought smh. – Martavis P. Commented May 1, 2014 at 8:42
Add a ment  | 

1 Answer 1

Reset to default 6

This is how I overlaid the collapsed menu. I wrote this to override Bootstrap:

 @media screen and (max-width: 768px)
    {
        .collapsing
        {
            position: absolute !important;
            z-index: 20;
            width: 100%;
            top: 50px;
        }
        .collapse.in {
            display: block;
            position: absolute;
            z-index: 20;
            width: 100%;
            top: 50px;
        }
        .navbar-collapse
        {
            max-height: none !important;
        }
    }

I used the media queries because I only wanted to affect the menu in the mobile view.

The class .collapsing is to make sure you are overlaying the page (z-index), stretching across the screen (presumably a phone) and are 50px from the top (the navbar class has a min-height: 50px).

The class .collapse.in is achieving the same as above, but for once the menu has already dropped.

What's under .navbar-collapse is to get rid of the max-height that bootstrap gives to dropdowns. I had a long menu so it may not be of need to others.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744334381a4569040.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信