I have one div position:fixed;
and my problem is that position fixed is relatively to all the page, I need that the fixed div stays inside other div that is centered in the page with margins in auto.(So when I scroll down the page I want to see always the div in the same position).
I use the jquery plugin StickyScroll but I can't make it work in Internet Explorer.
The solution could be in jquery/javascript , css.
Thanks
Set position: absolute; on the element that you want to position. Set position: relative; on the centered div so that it becomes a layer that you can position elements inside.
A pinned-down menu. The interesting rule here is the ' position: fixed ', that makes the DIV stay fixed on the screen. The ' top: 50% ' and ' right: 0 ' determine where the DIV is displayed, in this case: 50% down from the top of the window, and a constant 0px from the right.
Then you don't want fixed positioning, but absolute positioning.
Set position: absolute;
on the element that you want to position. Set position: relative;
on the centered div so that it becomes a layer that you can position elements inside.
You definitely don't need jQuery or JavaScript to achieve this. This is what you need:
.outer {
width:200px;
height:600px;
background-color:red;
margin:0 auto;
}
.inner {
width:50px;
border:1px solid white;
position:fixed;
}
<div class="outer">
<div class="inner">some text here
</div>
</div>
Have a look at this: http://jsfiddle.net/2mYQe/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With