애니메이션 효과를 이용해서 공지사항 용으로 자주 사용되는 텍스트를 위아래로 자동으로 움직여주는 슬라이드를 만들어보자
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<div class="content"> <div class="content__container"> <p class="content__container__text"> #WE </p>
<ul class="content__container__list"> <li class="content__container__list__item">create</li> <li class="content__container__list__item">share</li> <li class="content__container__list__item">innovate !</li>
</ul> </div> |
CSS
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
body { width: 100%; height: 100%; position: fixed; background-color: #34495e; }
.content { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); height: 160px; overflow: hidden; font-family: 'Lato', sans-serif; font-size: 35px; line-height: 40px; color: #ecf0f1; } .content__container { font-weight: 600; overflow: hidden; height: 40px; padding: 0 40px; } .content__container:before { content: '['; left: 0; } .content__container:after { content: ']'; position: absolute; right: 0; } .content__container:after, .content__container:before { position: absolute; top: 0; color: #16a085; font-size: 42px; line-height: 40px; -webkit-animation-name: opacity; -webkit-animation-duration: 2s; -webkit-animation-iteration-count: infinite; animation-name: opacity; animation-duration: 2s; animation-iteration-count: infinite; } .content__container__text { display: inline; float: left; margin: 0; } .content__container__list { margin-top: 0; padding-left: 110px; text-align: left; list-style: none; -webkit-animation-name: change; -webkit-animation-duration: 10s; -webkit-animation-iteration-count: infinite; animation-name: change; animation-duration: 10s; animation-iteration-count: infinite; } .content__container__list__item { line-height: 40px; margin: 0; }
@-webkit-keyframes opacity { 0%, 100% { opacity: 0; } 50% { opacity: 1; } } @-webkit-keyframes change { 0%, 12.66%, 100% { transform: translate3d(0, 0, 0); } 16.66%, 29.32% { transform: translate3d(0, -25%, 0); } 33.32%,45.98% { transform: translate3d(0, -50%, 0); } 49.98%,62.64% { transform: translate3d(0, -75%, 0); } 66.64%,79.3% { transform: translate3d(0, -50%, 0); } 83.3%,95.96% { transform: translate3d(0, -25%, 0); } } @-o-keyframes opacity { 0%, 100% { opacity: 0; } 50% { opacity: 1; } } @-o-keyframes change { 0%, 12.66%, 100% { transform: translate3d(0, 0, 0); } 16.66%, 29.32% { transform: translate3d(0, -25%, 0); } 33.32%,45.98% { transform: translate3d(0, -50%, 0); } 49.98%,62.64% { transform: translate3d(0, -75%, 0); } 66.64%,79.3% { transform: translate3d(0, -50%, 0); } 83.3%,95.96% { transform: translate3d(0, -25%, 0); } } @-moz-keyframes opacity { 0%, 100% { opacity: 0; } 50% { opacity: 1; } } @-moz-keyframes change { 0%, 12.66%, 100% { transform: translate3d(0, 0, 0); } 16.66%, 29.32% { transform: translate3d(0, -25%, 0); } 33.32%,45.98% { transform: translate3d(0, -50%, 0); } 49.98%,62.64% { transform: translate3d(0, -75%, 0); } 66.64%,79.3% { transform: translate3d(0, -50%, 0); } 83.3%,95.96% { transform: translate3d(0, -25%, 0); } } @keyframes opacity { 0%, 100% { opacity: 0; } 50% { opacity: 1; } } @keyframes change { 0%, 12.66%, 100% { transform: translate3d(0, 0, 0); } 16.66%, 29.32% { transform: translate3d(0, -25%, 0); } 33.32%,45.98% { transform: translate3d(0, -50%, 0); } 49.98%,62.64% { transform: translate3d(0, -75%, 0); } 66.64%,79.3% { transform: translate3d(0, -50%, 0); } 83.3%,95.96% { transform: translate3d(0, -25%, 0); } }
|
'Front-end > HTML' 카테고리의 다른 글
Noto Fonts :: 노토산스 한글 폰트 다운받고 설치하기 (0) | 2021.04.14 |
---|---|
나눔바른고딕 적용하기 (0) | 2019.05.13 |
여러가지색 그라데이션 :: 그라디언트 적용 (0) | 2019.03.25 |
svg 이미지 만들기 (2) | 2019.03.11 |
파비콘 만들기및 등록하기 (0) | 2019.03.10 |
댓글