3

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.

hamzanatek
  • 404
  • 3
  • 11
  • 1
    Possible duplicate of [Make column fixed position in bootstrap](http://stackoverflow.com/questions/21868610/make-column-fixed-position-in-bootstrap) – BENARD Patrick Apr 08 '16 at 16:52
  • 2
    no it doesnt work for me i want the same as facebook not like this maybe with a javascript code or something but i want the same as facebook – hamzanatek Apr 08 '16 at 17:31
  • 1
    You aren't showing us any css. Could you post your CSS as well? At this point, you literally only have boilerplate HTML... – Evan Bechtol Apr 08 '16 at 17:42
  • How is the duplicate different from what you want? – kirkpatt Apr 08 '16 at 18:21
  • I'm sorry, it may be a *possible* duplicate, but it wasn't. I retract my close vote, I apologize I'm confused. – BENARD Patrick Apr 08 '16 at 19:48

1 Answers1

2

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

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

http://codeply.com/go/oThW0CigtE

Carol Skelly
  • 351,302
  • 90
  • 710
  • 624