본문 바로가기
css trick & base

animate.css aos 에니메이션 효과주기

by uni:D 2024. 7. 24.

*****레이어팝업

밑에서 위로 올라오는 css로 일반적으로 줄때

#밑 (안보일때)

transform: translateY(100%);

#위 (보일때 - 클래스 붙음)

transform: translateY(0);

 

 

 

1. animate.css 오직 css만으로 가능 동작은 화면 보일때 한번만

https://animate.style/

 

2. aos 스크립트로 화면에서 꽂아주는 형태 한번만, 보일때마다 설정가능

https://michalsnik.github.io/aos/

 

*글자가 감춰졌다가 올라오는 느낌은 바깥영역을 오버플로우 히든으로 주면 그런느낌을 낼 수 있다

<div class="overflowHidden">
    <p class="title animate__animated animate__slideInUp">
      타이틀이 올라오는건데 오버플로우 히든한경우
    </p>
  </div>

 

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
.animate__animated {
    animation-duration: 1s;
    animation-fill-mode: both/* 에니메이션 최종 스타일 유지 */
}
@keyframes slideInUp {
    0% {
        -webkit-transform: translate3d(0,100%,0);
        transform: translate3d(0,100%,0);
        visibility: visible
    }
 
    to {
        -webkit-transform: translateZ(0);
        transform: translateZ(0)
    }
}
.animate__slideInUp {
    -webkit-animation-name: slideInUp;
    animation-name: slideInUp
}
 
.animate__fadeInUp {
    animation-name: fadeInUp
}
@keyframes fadeInUp {
    0% {
        opacity: 0;
        -webkit-transform: translate3d(0,100%,0);
        transform: translate3d(0,100%,0)
    }
    to {
        opacity: 1;
        -webkit-transform: translateZ(0);
        transform: translateZ(0)
    }
}
 
 
 
/* aos예시 */
/* 1. 처음화면 초기설정 */
[data-aos] {
  transition-duration: 1s;  
  transition-timing-function: cubic-bezier(.175,.885,.32,1.275);
}
[data-aos^=fade] {
    opacity: 0;
    transition-property: opacity,transform
}
/* 2. 화면이 보이면 aos-animate 클래스가 붙으면 => 공통 속성 */
[data-aos^=fade][data-aos^=fade].aos-animate {
    opacity: 1;
    transform: translateZ(0)
} 
 
/* ==================================== */
[data-aos=fade-up] {
    transform: translate3d(0,100px,0)
    /* 왼쪽값이 왼쪽오른쪽 / 가운데값이 위아래 */
}
[data-aos=fade-down] {
    transform: translate3d(0,-100px,0)
}
 
[data-aos=fade-right] {
    transform: translate3d(-100px,0,0)
}
 
[data-aos=fade-left] {
    transform: translate3d(100px,0,0)
}
 
cs