• January 30, 2024
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--slide-->
    <style>
    #slider {
      position: relative;
      width: 50%;
      height: 32vw;
      margin: 150px auto;
      font-family: 'Helvetica Neue', sans-serif;
      perspective: 1400px;
      transform-style: preserve-3d;
    }
    
    input[type=radio] {
      position: relative;
      top: 108%;
      left: 50%;
      width: 18px;
      height: 18px;
      margin: 0 15px 0 0;
      opacity: 0.4;
      transform: translateX(-83px);
      cursor: pointer;
    }
    
    
    input[type=radio]:nth-child(5) {
      margin-right: 0px;
    }
    
    input[type=radio]:checked {
      opacity: 1;
    }
    
    
    
    
    #slider label,
    #slider label img {
      position: absolute;
      width: 100%;
      height: 100%;
      left: 0;
      top: 0;
      color: white;
      font-size: 70px;
      font-weight: bold;
      border-radius: 3px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: transform 400ms ease;
    }
    
    
    
    /* Slider Functionality */
    
    /* Active Slide */
    #s1:checked ~ #slide1,
     #s2:checked ~ #slide2,
      #s3:checked ~ #slide3,
       #s4:checked ~ #slide4,
        #s5:checked ~ #slide5 {
      box-shadow: 0 13px 26px rgba(0,0,0, 0.3), 0 12px 6px rgba(0,0,0, 0.2);
      transform: translate3d(0%, 0, 0px);
    }
    
    /* Next Slide */
    #s1:checked ~ #slide2,
     #s2:checked ~ #slide3,
      #s3:checked ~ #slide4,
       #s4:checked ~ #slide5,
        #s5:checked ~ #slide1 {
      box-shadow: 0 6px 10px rgba(0,0,0, 0.3), 0 2px 2px rgba(0,0,0, 0.2);
      transform: translate3d(20%, 0, -100px);
    }
    
    
    /* Next to Next Slide */
    #s1:checked ~ #slide3,
     #s2:checked ~ #slide4,
      #s3:checked ~ #slide5,
       #s4:checked ~ #slide1,
        #s5:checked ~ #slide2 {
      box-shadow: 0 1px 4px rgba(0,0,0, 0.4);
      transform: translate3d(40%, 0, -250px);
    }
    
    /* Previous to Previous Slide */
    #s1:checked ~ #slide4,
     #s2:checked ~ #slide5,
      #s3:checked ~ #slide1,
       #s4:checked ~ #slide2,
        #s5:checked ~ #slide3 {
      box-shadow: 0 1px 4px rgba(0,0,0, 0.4);
      transform: translate3d(-40%, 0, -250px);
    }
    
    /* Previous Slide */
    #s1:checked ~ #slide5,
     #s2:checked ~ #slide1,
      #s3:checked ~ #slide2,
       #s4:checked ~ #slide3,
        #s5:checked ~ #slide4 {
      box-shadow: 0 6px 10px rgba(0,0,0, 0.3), 0 2px 2px rgba(0,0,0, 0.2);
      transform: translate3d(-20%, 0, -100px);
    }
      /* Add a class to make the transition smoother */
      .transition {
        transition: transform 400ms ease, box-shadow 400ms ease;
      }
    </style>	
    
    <section id="slider">
      <input type="radio" name="slider" id="s1" checked>
      <input type="radio" name="slider" id="s2">
      <input type="radio" name="slider" id="s3">
      <input type="radio" name="slider" id="s4">
      <input type="radio" name="slider" id="s5">
    
      <label for="s1" id="slide1"><img src="http://www.bkintercontech.com/wp-content/uploads/2024/01/cannabis-samrt-farm-1a-1024x682.jpg" alt=""></label>
      <label for="s2" id="slide2"><img src="http://www.bkintercontech.com/wp-content/uploads/2024/01/cannabis-samrt-farm-1b-1024x682.jpg" alt=""></label>
      <label for="s3" id="slide3"><img src="http://www.bkintercontech.com/wp-content/uploads/2024/01/cannabis-samrt-farm-1c-1024x682.jpg" alt=""></label>
      <label for="s4" id="slide4"><img src="http://www.bkintercontech.com/wp-content/uploads/2024/01/cannabis-samrt-farm-1d-1024x682.jpg" alt=""></label>
      <label for="s5" id="slide5"><img src="http://www.bkintercontech.com/wp-content/plugins/icyclub/inc/industryup/images/slider/banner.jpg" alt=""></label>
    </section>
    
    <!--slide-->
    <script>
        function nextSlide() {
          const currentSlide = document.querySelector('input[type="radio"]:checked');
          const nextSlide = currentSlide.nextElementSibling || document.querySelector('input[type="radio"]:first-child');
          nextSlide.checked = true;
        }
        setInterval(nextSlide, 2000);
    </script>
    

    ทำให้ loop

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            let currentSlide = 1;
    
            function switchSlide() {
                // Add a class to make the transition smoother
                document.querySelector('#slider').classList.add('transition');
    
                // Check if the next slide is the first one (looping back to the beginning)
                currentSlide = (currentSlide % 5) + 1;
                document.querySelector(`#s${currentSlide}`).checked = true;
            }
    
            // Remove the transition class after the transition ends
            document.querySelector('#slider').addEventListener('transitionend', function() {
                document.querySelector('#slider').classList.remove('transition');
            });
    
            setInterval(switchSlide, 3000); // Adjusted timing to account for the transition duration and interval
        });
    </script>
    


เวอไนน์ไอคอร์ส

ประหยัดเวลากว่า 100 เท่า!






เวอไนน์เว็บไซต์⚡️
สร้างเว็บไซต์ ดูแลเว็บไซต์

Categories