Advertisement
asimryu

css-slide.html css만으로 버튼 누르면 이미지 슬라이드

Jun 21st, 2018
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.74 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: 900px;
  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/900/300/nature");
  54.         }
  55.  
  56.         .imgslide li:nth-child(2) {
  57.             background-image: url("http://placeimg.com/900/300/people");
  58.         }
  59.  
  60.         .imgslide li:nth-child(3) {
  61.             background-image: url("http://placeimg.com/900/300/tech");
  62.         }
  63.  
  64.         .imgslide li:nth-child(4) {
  65.             background-image: url("http://placeimg.com/900/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: 30px;
  102.             height: 30px;
  103.             background-color: #ddd;
  104.             border: 1px solid #333;
  105.             display: inline-block;
  106.             text-align: center;
  107.             line-height: 30px;
  108.             cursor: pointer;
  109.         }
  110.         label:hover { background-color: red; color: white; }
  111.  
  112.         #s1:checked ~ .imgslide{left: 0}
  113.         #s2:checked ~ .imgslide{left: -100%}
  114.         #s3:checked ~ .imgslide{left: -200%}
  115.         #s4:checked ~ .imgslide{left: -300%}
  116.  
  117.         .radio { display: none; }
  118.     </style>
  119. </head>
  120. <body>
  121.    
  122.     <section id="visual">
  123.         <label for="s1">1</label>
  124.         <input type="radio" name="btn" id="s1" class="radio" checked>  
  125.         <label for="s2">2</label>
  126.         <input type="radio" name="btn" id="s2" class="radio">
  127.         <label for="s3">3</label>
  128.         <input type="radio" name="btn" id="s3" class="radio">
  129.         <label for="s4">4</label>
  130.         <input type="radio" name="btn" id="s4" class="radio">
  131.         <ul class="imgslide">
  132.             <li></li>
  133.             <li></li>
  134.             <li></li>
  135.             <li></li>
  136.         </ul>
  137.     </section>
  138.  
  139. </body>
  140. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement