Advertisement
asimryu

css animation 버튼 누르면 슬라이드

Apr 10th, 2018
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.47 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Document</title>
  6.     <style>
  7.         * {
  8.             margin: 0 auto;
  9.             padding: 0;
  10.             list-style: none;
  11.             box-sizing: border-box;
  12.         }
  13.  
  14.         #visual {
  15.             width: 600px;
  16.             height: 300px;
  17.             position: relative;
  18.             overflow: hidden;
  19.             margin: 0 auto;
  20.         }
  21.  
  22.         @keyframes slide {
  23.             0% { margin-left:0; }
  24.             20% { margin-left:0; }
  25.             25% { margin-left:-100%; }
  26.             45% { margin-left:-100%; }
  27.             50% { margin-left:-200%; }
  28.             70% { margin-left:-200%; }
  29.             75% { margin-left:-300%; }
  30.             95% { margin-left:-300%; }
  31.             100% { margin-left:0; }
  32.         }
  33.  
  34.         .imgslide {
  35.             width: 400%;
  36.             height: 300px;
  37.             float: left;
  38.             position: relative;
  39.             transition: all 0.5s;
  40.         }
  41.  
  42.  
  43.  
  44.         .imgslide li {
  45.             width: 25%;
  46.             height: 600px;
  47.             float: left;
  48.             background-size: cover;
  49.             background-position: center;
  50.         }
  51.  
  52.         .imgslide li:nth-child(1) {
  53.             background-image: url("http://placeimg.com/600/300/nature");
  54.         }
  55.  
  56.         .imgslide li:nth-child(2) {
  57.             background-image: url("http://placeimg.com/600/300/people");
  58.         }
  59.  
  60.         .imgslide li:nth-child(3) {
  61.             background-image: url("http://placeimg.com/600/300/tech");
  62.         }
  63.  
  64.         .imgslide li:nth-child(4) {
  65.             background-image: url("http://placeimg.com/600/300/arch");
  66.         }
  67.  
  68.         .btns {
  69.             width: 50px;
  70.             height: 50px;
  71.             border-radius: 50%;
  72.             background-color: #FFF;
  73.             color: #000;
  74.             text-align: center;
  75.             line-height: 50px;
  76.             position: absolute;
  77.             top: 50%;
  78.             transform: translateY(-50%);
  79.             display: block;
  80.             z-index: 999;
  81.         }
  82.  
  83.         .btns-left {
  84.             left: 10px;
  85.         }
  86.         .btns-left::before {
  87.             content: "<";
  88.         }
  89.         .btns-right {
  90.             right: 10px;
  91.         }
  92.         .btns-right::before {
  93.             content: ">";
  94.         }
  95.  
  96.         .btns-right:focus + .imgslide {
  97.             animation: 2s slide1 forwards;
  98.         }
  99.  
  100.         label{
  101.             width: 10px;
  102.             height: 10px;
  103.             background-color: #000
  104.         }
  105.  
  106.         #s1:checked ~ .imgslide{left: 0}
  107.         #s2:checked ~ .imgslide{left: -100%}
  108.         #s3:checked ~ .imgslide{left: -200%}
  109.         #s4:checked ~ .imgslide{left: -300%}
  110.     </style>
  111. </head>
  112. <body>
  113.    
  114.     <section id="visual">
  115.         <label for="s1">1</label>
  116.         <input type="radio" name="btn" id="s1" checked>
  117.         <label for="s2">1</label>
  118.         <input type="radio" name="btn" id="s2">
  119.         <label for="s3">1</label>
  120.         <input type="radio" name="btn" id="s3">
  121.         <label for="s4">1</label>
  122.         <input type="radio" name="btn" id="s4">
  123.         <ul class="imgslide">
  124.             <li></li>
  125.             <li></li>
  126.             <li></li>
  127.             <li></li>
  128.         </ul>
  129.     </section>
  130.  
  131. </body>
  132. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement