I am trying to create fixed position div inside relative container. I am using bootstrap css framework. I am trying to create a fixed position cart. So whenever user scroll page it will show cart contents. but now problem is, it ran outside that container div.
This has to work in responsive mode.
Here my try:
.wrapper { width: 100% } .container { width: 300px; margin: 0 auto; height: 500px; background: #ccc; } .element { background: #f2f2f2; position: fixed; width: 50px; height: 70px; top: 50px; right: 0px; border: 1px solid #d6d6d6; } <div class="wrapper"> <div class="container"> <div class="element"> fixed </div> </div> </div> 
leftandtopwhile also usingposition: fixed; otherwise, you're overriding it completely.