jquery - Float div on top of div that has scroll-y -


so want div scroll when user scrolls div (notice div) down. here's html:

<body> <div class="container"> <div class="floaty">yep</div> content </div> 

so container 700px height (dynamic height depending on content inside) has set in css scroll y , x. when srolling content don't scroll whole page. floaty thing keeps still top of div though has position fixed. believe it's because browser looks page not scrolling doesn't move it.

container has position relative set. how can make scroll? jquery way?

here try:

.container{     height:200px;     border:1px solid red;     margin-top:50px;     width:100%;     overflow-y:scroll; } .floaty{     position:fixed;     width:100%;     height:50px;     border:1px solid green;     top:0px; } 

i not sure final result expect, if not -please,clarify.

demo here


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -