html - Scroll within a fixed position overlay -
jsbin. click buttons on left. first 1 example of overlay doesn't require scroll (so works perfectly), second button nothing, , third button problem i'm describing. note copied/pasted zenpen style before main style in css tab.
i'm using bootstrap 3.0 , zenpen. idea have menu on left side of screen can click button hide , show different 'applications' or overlays. these overlays using position: fixed
, can't zenpen overlay or else won't able scroll within it.
if change #wordinner { position: fixed;
#wordinner { position: absolute;
instead, able scroll, won't take entire page (instead centered in middle of screen normal container
class. in jsbin, it's on position: absolute
, change see problem i'm talking about.
the logic behind code use col-lg-12
, , style same div take entire page (because width: 100%
won't work.)
main css:
#wrap { position: relative; } #main { position: relative; }
zenpen's css (a link default zenpen css):
#word { overflow: hidden; text-shadow: none; } #word b, #word strong { color: #000; } #wordinner { position: fixed; top: 0; left: 0; width: 100%; height: 100%; padding: 5px; /* because nav 100 px, zenpen's icon menu 65px */ padding-left: 165px; } #word { overflow-y: scroll; -webkit-transition: 600ms; -moz-transition: 600ms; -ms-transition: 600ms; -o-transition: 600ms; transition: 600ms; } #word section { height: 100%; margin: auto; }
and relevant html (link zenpen html: zenpen html):
<div class="container" id="wrap"> <div class="container" id="main"> <!-- snip irrelevant html --> </div> </div> <div class="container" id="apps"> <div class="row"> <div class="col-lg-12" id="appsinner"> <div><a href="#" id="close_apps">close</a></div> <input type="text" class="form-control" placeholder="search here" /> </div> </div> </div> <div class="container" id="word"> <div class="row"> <div class="col-lg-12 yin" id="wordinner" > <div><a href="#" id="close_word">close</a></div> <!-- snip zenpen html --> </div> </div> </div> </div> </div> <nav> <ul> <li><a href="#" class="btn light" id="open_apps"><span class="entypo-search"></span></a><span class='button-text'>apps</span></li> <li><a href="#" class="btn red" id="home"><span class="entypo-home"></span></a><span class='button-text'>home</span></li> <li><a href="#" class="btn green" id="open_word"><span class="entypo-leaf"></span></a><span class='button-text'>word</span></li> </ul> </nav>
you set overflow on html, body
overflow: hidden
, set #wordinner { position: fixed; overflow: auto;
. ensure there 1 visible scrollbar on right hand side of page, , when needed. if need overflow
set visible
other pages, set using jquery (since using anyway) when open , close #word
app.
option 1 (using css only): jsbin
html, body { overflow: hidden; } #wordinner { position: fixed; overflow: auto; ... }
option 2 (using css , jquery): jsbin
css
#wordinner { position: fixed; overflow: auto; ... }
jquery
$("#open_word").click(function(event) { event.preventdefault(); $("html, body").css("overflow", "hidden"); $("#word").show(); }); $("#close_word").click(function(event) { event.preventdefault(); $("html, body").css("overflow", "visible"); $("#word").hide(); });
Comments
Post a Comment