javascript - Hyperlink and fragment ID Vertical Offset Problem -
javascript - Hyperlink and fragment ID Vertical Offset Problem -
at top of page statically positioned menu strip follows screen during scrolling.
when using fragment linking scroll position needs offset height of menu strip. how can achieved?
<a href="#fragment">go fragment</a> <div id="fragment">...</div> html { padding-top: 38px; } /* offset page allow menu strip */ .menu-strip { position: fixed; top: 0; right: 0; left: 0; height: 38px; }
is there simple css alter can made accomplish this?
otherwise, there generic way offset scrolling 200px when fragment specified?
what want create handle own hash linking. thought grouping of a
hash linking. example
$(".ahashlink").click( function() { var location = $(this).attr("href"); var offset = $(location).offset().top; $("body").scrolltop(offset+38); homecoming false; });
this scroll right place plus 38 more pixels (the height of top bar). this, however, not alter url in browser contain right hash. because 1 time have window.location.hash = "#something"
window automatically scroll hash. maintain in mind.
javascript jquery html css html5
Comments
Post a Comment