hamzanatek
hamzanatek

Reputation: 404

make a column on bootstrap fixed

I'm working with bootstrap and I want to make a div fixed and scroll only content, like how Facebook uses the right sidebar fixed and the timeline scrolled.

I WANT THE SAME AS FACEBOOK NOT LIKE THE OTHER PROPOSITION ON STACKOVERFLOW

my code looks like:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-8 layout-content-container">

        </div>
        <div class="col-md-4 layout-content-container">
        </div>
    </div>
</div>

</body>
</html>

I want to make the col-md-8 scrolled and the col-md-4 fixed.

Upvotes: 3

Views: 92

Answers (1)

Carol Skelly
Carol Skelly

Reputation: 362360

Just use position:fixed to attach the sidebar...

#sidebar {
    height: 100%;
    position: fixed;
    right: 0;
    overflow-y: auto;
}

http://codeply.com/go/oThW0CigtE

Upvotes: 2

Related Questions