jquery - How to float div to the side and have it sticky while scrolling -


so have divs hidden shown when click span id corresponds div class. have park working , show divs have long list of things goes off page. want hidden divs sticky top of screen if user clicks link far down don't have scroll way top in order see it. here code should give idea of i'm working with.

html:

<div id='container'>     <div id='nav'>         nav things     </div     <div id='main'>         <span class='clickme' id='1'>thing 1</span>         <span class='click me' id='2'>thing 2</span>         etc..     </div>     <div class="div_class 1'>         explanation of thing 1.     </div>     <div class='div_class 2'>         explanation of thing 2.     </div> </div 

css:

#container {     margin: 0px auto;     width: 90%; } #nav {     float: left;     width: 15%; } #main {     float: left;     width: 15%; } .div_class {     float: right;     display: none; } 

i have tried 'posistion: fixed' on div_class class puts text top left overlapping nav div. tried adding padding made div overlap of links , made them un-clickable.

you on right track position: fixed. need tell element go:

#floater {     position: fixed;     top: 0;     right: 0; } 

adjust top , right (or left , bottom if wish) needed avoid overlapping navigation div.

see this jsfiddle bare-bones demonstration, , this one navigation bar.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -