I\'m using absolute positioning to have a div fill up the entire browser window. However, I wan\'t to combine this with a sticky div that sometimes is there and sometimes no
2018-6-18
I choose the CSS way with position: sticky
.
that https://github.com/abouolia/sticky-sidebar .
doesn't work for me (I am using Vue.js 2.0 SPA with vue-router & vuex)
I also want the element position: absolute
first,
and then position: sticky
position: absolute
to have the right position.(don't forget to set height
for parent. for example height:100%
)
position: sticky
work for me.
Use float: left; and width: 0; and you can use transform: translateX(xxx); for set left position.
Problem solved :)
The alert scrolls with the content because it's inside the content-area which has overflow-y: auto
.
Move it out of the content-area (put it in between subheader and content-area), and remove the position: absolute
(and top/left/right/bottom) attributes from the content. In that example I see no reason for content to be absolute-positioned, normal flow will put it where it wants to be.
edit
update with some enhancements
http://jsfiddle.net/aDdRS/11/
first post
Why not scroll just the .content
and not the .content-area
http://jsfiddle.net/aDdRS/8/
See http://jsfiddle.net/aDdRS/5/
I chose to go with a JavaScript approach after all. Would have preferred a pure CSS approach but my need for IE8 support stood in the way. This answer by Myles Gray is pretty much what I did - https://stackoverflow.com/a/4933509/940517