Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 685
hamzanatek Avatar asked Mar 28 '26 22:03

hamzanatek


1 Answers

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

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

http://codeply.com/go/oThW0CigtE

like image 182
Zim Avatar answered Mar 31 '26 04:03

Zim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!