Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter bootstrap - Fixed layout with scrollable sidebar

I am trying to implement a simple header + 2 column layout using twitter bootstrap.

I have a fixed header with 100% width, and I am now trying to have two fixed-width full-height columns with independent scrollbars. Is there any good way to do this with twitter bootstrap?

Here is a picture of the layout I am trying to build Layout

like image 557
Rand Avatar asked Apr 03 '12 16:04

Rand


2 Answers

Use bootstrap's 'pre-scrollable' class on your target div. Set div at some fixed max height. Its aesthetically good, as well.

like image 113
Sourajit Basak Avatar answered Oct 19 '22 15:10

Sourajit Basak


I found a way to do it. Not sure it's the best, but it does the trick:

<html>

<head>

    <link rel="stylesheet" media="screen" href="normalize.css">
    <link rel="stylesheet" media="screen" href="bootstrap.min.css">

    <style type="text/css">
            body, html {
                height: 100%;
                overflow: hidden;
            }

            .navbar-inner {
                height: 40px;
            }

            .scrollable {
                height: 100%;
                overflow: auto;
            }

            .max-height {
                height: 100%;
            }

            .no-overflow {
                overflow: hidden;
            }

            .pad40-top {
                padding-top: 40px;
            }
    </style>
</head>

<body>

    <div class="navbar navbar-fixed-top">
        <div class="navbar-inner">
            <div class="container">
                header contents
            </div>
        </div>
    </div>

    <div class="container max-height no-overflow">
        <div class="row max-height">

            <div class="span8 scrollable">
                <div class="pad40-top">
                    main contents
                </div>
            </div>

            <div class="span4 scrollable">
                <div class="pad40-top">
                    right sidebar contents
                </div>
            </div>

        </div>
    </div>
</body>

http://jsfiddle.net/m4eS4/7/

like image 8
Rand Avatar answered Oct 19 '22 16:10

Rand