본문 바로가기
Coding/HTML & CSS

[HTML & CSS] 슬라이드(slide) 위로 올라가는 방향

by 포스트it 2020. 11. 9.
728x90
반응형

- code -

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>slide</title>

  <style>
    *{margin:0;padding:0;}
    ul,li{list-style:none;}
    .slide{height:300px;overflow:hidden;}
    .slide ul{height:calc(100% * 4);animation:slide 8s infinite;}
    .slide li{height:calc(100% / 4);}
    .slide li:nth-child(1)
    .slide li:nth-child(2)
    .slide li:nth-child(3)
    .slide li:nth-child(4){background:none;}
    @keyframes slide {
      0% {margin-top:0;}
      10% {margin-top:0;}
      25% {margin-top:-300px;}
      35% {margin-top:-300px;}
      50% {margin-top:-600px;}
      60% {margin-top:-600px;}
      75% {margin-top:-900px;}
      85% {margin-top:-900px;}
      100% {margin-top:0;}
    }
  </style>

</head>
<body>
  <div class="slide">
    <ul>
      <li><a href="#"><img src="https://img1.daumcdn.net/thumb/R720x0.q80/?scode=mtistory2&fname=http%3A%2F%2Fcfile24.uf.tistory.com%2Fimage%2F14177447505423BD353D6F" alt=""></a></li>
      <li><a href="#"><img src="https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTBzdDK_GhLhi3W-lu7Yii9-5qtDyORM3asiw&usqp=CAU" alt=""></a></li>
      <li><a href="#"><img src="https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcT4x_2tbNBNyAdmZ8sUTGTnmdvkGhc2QA_LtA&usqp=CAU" alt=""></a></li>
      <li><a href="#"><img src="https://img1.daumcdn.net/thumb/R720x0.q80/?scode=mtistory2&fname=http%3A%2F%2Fcfile3.uf.tistory.com%2Fimage%2F1643FE47505423BD092340" alt=""></a></li>
    </ul>
  </div>
</body>
</html>

결과물

 

slide

 

728x90
반응형

댓글