I'm

Developer, Designer, Photographer

GET IN TOUCH

  • Buk-gu, Busan, Republic of Korea
  • ungdoli0916@naver.com
  • Kakao ID : Ungdoli
Your message has been sent. Thank you!
(즐거웅코드) 자바스크립트 스크롤 맨 아래로 내리기

· 즐거'웅' 코드 (Source)/HTML & CSS & JAVASCRIPT
2020. 3. 19. 21:17

반응형
JAVASCRIPT
1
2
3
<script>
    document.body.scrollTop = document.body.scrollHeight;
</script>
예제 소스
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<style>
    body {
        width: 100%;
        height: 2500px;
        margin: 0;
        padding: 0;
        background: linear-gradient(#e66465, #9198e5);
        position: relative;
    }
  
    body div {
        position: absolute;
        width: 200px;
        height: 70px;
        line-height: 70px;
        text-align: center;
        font-size: 24px;
        top: 100px;
        left: 50%;
        transform: translate(-50%, -50%);
        background-color: #ffffff;
        border-radius: 15px;
        border: 1px solid rgba(0, 0, 0, 0.15);
        cursor: pointer;
    }
</style>
  
<body>
<div onclick="test()">스크롤 아래로</div>
</body>
  
<script>
    function test() {
        document.body.scrollTop = document.body.scrollHeight;
    }
</script>
구현 예시
반응형