Twitter Bootstrap2 100% height responsive

前端 未结 3 2036
遇见更好的自我
遇见更好的自我 2020-12-24 13:28

I want to make a responsive layout with twitter\'s bootstrap v2, with a column and a map.

The idea is to build a UI like that from maps.google.com, but using a respo

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

    From my investigations this week (I'm trying to accomplish the same thing), it seems like bootstrap and a 100%-height design are incompatible from a pure CSS perspective (unless you want to make changes to bootstrap). I'd be interested in seeing your jquery solution.

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

    here is the solution I found using JQuery (I think it's easy to do with plain js)

    $(window).bind('resize', function() {
        if ( $(window).width() > 980 ) {
            $("#content").height(($(window).height()-40)+"px")
            $("#sidebar").height(($(window).height()-58)+"px")
            $("body").css("padding-top","40px")
        }
        else {
            $("#content").height(($(window).height()-50)+"px")
            $("#sidebar").height(($(window).height()-68)+"px")
            $("body").css("padding-top","0px")            
        }
    
        $("#sidebar").css("overflow", "auto")
        $("body").css("padding-bottom","0px")
        $(".navbar").css("margin-bottom","0px")
    });
    

    The $(selector).css() functions and the conditional if could be replaced with plain css and the media queries from CSS3 http://twitter.github.com/bootstrap/scaffolding.html#responsive

    But the problem is that $(window).height() is calculated runtime. That should be replaced maybe by something like a height:100% in CSS, and that could do the trick, but I couldn't find the right place to put that 100% height.

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

    I'm not sure that I totally understand what you are looking for, but take a look at http://reactivewebdesign.net/Chicago/Traffic which has a top menu (adding the bootstrap navbar should be easy).

    The left column spans 3 columns and the map occupies 9 columns. There is also a link in the left menu named "Where Am I" that also uses a Google map. The css for the map is at the top of the page. If you are looking to squeeze the map into three columns, merely reverse the 3 & 9 to 9 & 3 - it should still work.

    Hope this helps.

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