Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
138
rated 0 times [  143] [ 5]  / answers: 1 / hits: 58290  / 11 Years ago, tue, november 5, 2013, 12:00:00

Couldn't find a tutorial for this anywhere or just didn't use the right keywords.
I'm making a one-paged website, and I'd like the navigation bar buttons to scroll the page up/down to the right part.
Would this be possible in just HTML and CSS?

I'm not so experienced with JavaScript.



Similar to ''Scroll to the top'' but that I could decide to where it scrolls the page, like middle, top, bottom etc. .


More From » html

 Answers
3

Update: There is now a better way to use this, using the HTML id attribute:



Set the destination id: <h1 id=section1>Section 1</h1>



And create a link to that destination using the anchor tag: <a href=#section1>Go to section 1</a>



The benefit of this new method is that the id attribute can be set on any HTML element. You don't have to wrap superfluous anchor tags around destination links anymore!



Original answer:



You can look at using the HTML anchor tag.



<a name=section1>Section 1</a>



alongside



<a href=#section1>Go to section 1</a>



When the user clicks on Go to section 1, they will be sent to the section of the page where the Section 1 text is displayed.


[#74489] Monday, November 4, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
chazw

Total Points: 127
Total Questions: 129
Total Answers: 92

Location: Sao Tome and Principe
Member since Wed, Dec 21, 2022
1 Year ago
;