html - Clicking on anchor links moves whole page to top -



html - Clicking on anchor links moves whole page to top -

so have webpage whole html's overflow hidden

html { overflow: hidden; }

and have nav bar has anchor links , div has content has overflow auto, it's scrollable.

nav:

<ul> <li><a href="#events">events</a></li> <li><a href="#jazz">jazz</a></li> <li><a href="#weddings">weddings</a></li> </ul>

content div:

<div class="content"> <div id="events">events</div> // content <div id="jazz">jazz</div> // content <div id="weddings">weddings</div> // content </div>

now, problem when click on link on nav, illustration jazz, whole page goes top, everything: nav, div content , obviously, div shows jazz section . there way stays in place , div content box scrolls section?

thanks!

given info provided wasn't able reproduce issue. or maybe i'm not understanding question.

the next (which built off code) works way seem want to.

class="snippet-code-html lang-html prettyprint-override"><!doctype html> <html> <head> <style type="text/css"> html {overflow: hidden;} div#content {height: 1500px;} div#events {height: 500px;background-color: green;} div#jazz {height: 500px;background-color: red;} div#weddings {height: 500px;background-color: blue;} </style> </head> <body> <ul> <li><a href="#events">events</a></li> <li><a href="#jazz">jazz</a></li> <li><a href="#weddings">weddings</a></li> </ul> <div class="content"> <div id="events">events</div> // content <div id="jazz">jazz</div> // content <div id="weddings">weddings</div> // content </div> </body> </html>

do intend pin navigation @ top of window when user scrolls lower content? if see smint tutorial on how build 1 page site sticky navigation bar. , purchase him coffee :)

html css hyperlink anchor

Comments

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -