javascript - CSS position fixed. Div wrapper must be fixed vertically but must be varying in horizontally -
i have div , this
#footer { position:fixed; left:40px; top:0px; } the position fixed when scroll vertically or horizontally. want div fixed when user scrolls scroll bar vertically should varying when user scrolls scroll-bar horizontally.
i have seen of forums , posts found jquery script.i want know if there way in css?
fixed position in 1 direction read post did not understand jquery script. kindly let me know way in css or better way jquery.thanks
seems impossible "look fine" css/html. mentioned ruup or fixed position in 1 direction, layering on js it, option.
fortunately, found way work somehow (not beautiful): http://jsfiddle.net/mkebw/5/
html (inside body-tag):
<div id="simulated-html"> <div id="footer"> <span> <!-- footer text here --> </span> </div> <div id="simulated-body"> <!-- website here --> </div> </div> css:
* { margin:0; padding:0; } html { font: 12px/1.5em georgia; } p { padding: 5px; } html, body { height: 100%; overflow: hidden; /* hide scrollbars, create our own */ } #simulated-html { background: orange; overflow-x: scroll; /* force horizontal scrollbars (optional) */ overflow-y: hidden; /* hide. use #simulated-body it. */ position: relative; /* align #footer on #simulated-html */ height: 100%; } #simulated-body { overflow-y: scroll; /* force vertical scrollbars (optional) */ overflow-x: hidden; /* hide. use #simulated-html it. */ height: 100%; background: #eee; /* use container */ width: 450px; margin: 0 auto; } #footer { position: absolute; bottom: 0px; /* vertical align #simulated-html */ width: 100%; background: red; z-index: 99; /* show footer */ color: white; } #footer span { width: 450px; margin: 0 auto; background: green; display: block; } seems work in ie7+ , modern browsers, tested via browserlab.adobe.com.
tested scrollbars, smaller , wider viewports in chrome 18.
i recommend fallback not capable browsers and/or js workaround.
Comments
Post a Comment