Web

[WEB] 페이지 스크롤 이동, 페이지 위치 이동시키기

2021. 11. 19. 13:23
목차
  1. 페이지 스크롤 자동으로 이동하기
  2. 방법
  3. 예시 코드
728x90
반응형

페이지 스크롤 자동으로 이동하기

특정 목차를 클릭하면 해당 글이 있는 곳으로 이동한다던지 하는 페이지를 본 적 있을 것이다.

클릭하면 특정 위치로 이동하는 예시

방법

이러한 기능은 아래와 같이

div의 id앞에 #을 붙인 주소를

a태그의 href로 넣어주어 동작시킬 수 있다.

<a href='#title1'>title1</a>
<div id="title1" class="title">title1</div>

예시 코드

아래의 코드를 실행해보자

<html>
<style type="text/css">
.title {
height: 700px;
}
</style>
<body>
<a href='#title1'>title 1</a>
<a href='#title2'>title 2</a>
<a href='#title3'>title 3</a>
<div id="title1" class="title">title1
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
<div id="title2" class="title">title2
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
<div id="title3" class="title">title3
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
<a href='#top'>top</a>
</body>
</html>

 

예시의 글은 Lipsum generator에서 가져왔다. Lipsum generator은 자동으로 dummy글을 생성해준다.

728x90
반응형

'Web' 카테고리의 다른 글

[Web] CORS란, CORS오류 해결  (0) 2022.03.03
[WEB] Restful API란? REST vs SOAP / 스크랩  (0) 2021.12.01
WAS와 WebServer  (0) 2021.09.03
Django 배우기  (0) 2021.08.20
npx와 npm  (0) 2021.08.18
  1. 페이지 스크롤 자동으로 이동하기
  2. 방법
  3. 예시 코드
'Web' 카테고리의 다른 글
  • [Web] CORS란, CORS오류 해결
  • [WEB] Restful API란? REST vs SOAP / 스크랩
  • WAS와 WebServer
  • Django 배우기
우주유령
우주유령
우주유령
우주
우주유령
전체
오늘
어제
반응형
  • 분류 전체보기 (131)
    • javascript (28)
    • java (26)
    • Web (16)
    • React (7)
    • SQL (2)
    • Spring (20)
    • IntelliJ (6)
    • JSP (1)
    • Notion (1)
    • VScode (8)
    • Vue (3)
    • css (1)
    • tistory (1)
    • jpa (8)
    • 책 (1)

블로그 메뉴

  • 홈
  • 태그

공지사항

인기 글

최근 글

hELLO · Designed By 정상우.
우주유령
[WEB] 페이지 스크롤 이동, 페이지 위치 이동시키기
상단으로

티스토리툴바

개인정보

  • 티스토리 홈
  • 포럼
  • 로그인

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.