javascript - Popup window to always appear fixed to top edge BUT scrolls with entire page if content larger than screen height? -
let me try , make sense. have search page returns lots of search results google. each of search results have trigger (via icon using onmouseover) access more info in popup window pops right of search results, google. here want popup window:
no matter if looking @ first search result @ top of page, or last search result way down @ bottom of page, want popup window align top edge of screen, regardless of vertically on page (similar fixed)
but, if popup window happens contain more data vertical screen height allows, instead of popup window creating scrollbars internally, want popup window scroll right along else on page (similar absolute)
the problem fixed chops off data goes below bottom of visible browser window height making inaccesible without internal scrollbars. absolute, popup scrolls along other stuff on page great , want, appears @ top of page, when @ bottom of page, making invisible user if results list long.
its trying combine 2 methods in way. summarize:
- when trigger popup via onmouseover, popup window should affix top edge no matter vertically, if content vertically taller screen allows, should able scroll entire page down see rest of it. should not have use internal scrollbars within popup window fixed.
is possible , how should go it? thanks!
you're going need javascript.
first, make set popup div
s position: absolute
. act fixed
in can go anywhere on page through left
, top
, still scrolls page.
on link hover, make js detect browser's scroll position (through window.offsety
or $(window).scrolltop()
in jquery). apply offset popup:
$('.link').on('click', function () { $('.preview').css('top', $(window).scrolltop()); });
remember tweak other css properties of popup suit needs - however, of can done in css; js need top
property.
fiddle: http://jsfiddle.net/gwvnx/
Comments
Post a Comment