“Slider HTML CSS” Kode Jawaban

Slider HTML CSS

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <style>
        /* ///headers profile for the css//// */
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            outline: none;
            text-decoration: none;
        }
        /* slider body */
        
        .background {
            height: 100vh;
            width: 100vw;
            position: relative;
            background-color: rgb(100, 100, 100);
        }
        
        .divmain {
            /* height: 500px;
    width: 80%; */
            height: 100%;
            width: 100%;
            position: absolute;
            top: 50%;
            left: 50%;
            background-color: #fff;
            transform: translate(-50%, -50%);
            background-image: url(../images/pexels-1.jpg);
            background-repeat: no-repeat;
            background-size: 100% 100%;
            box-shadow: 2px 4px 6px 6px rgb(0, 0, 0);
            animation: slider 15s infinite linear;
        }
        
        h1 {
            position: absolute;
            color: rgb(0, 0, 0);
            text-align: center;
            top: 20%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 5rem;
            font-weight: 800;
        }
        
        .glow {
            font-size: 80px;
            color: #fff;
            text-align: center;
            animation: glow 1s ease-out infinite alternate;
        }
        
        .mask {
            background-color: rgba(0, 0, 0, 0.459);
            height: 100%;
            width: 100%;
            background-position: center;
            background-repeat: no-repeat;
            background-size: cover;
        }
        
        @keyframes glow {
            from {
                text-shadow: 0 0 10px rgb(108, 238, 255), 0 0 20px rgb(108, 238, 255), 0 0 30px #ccc, 0 0 40px #ccc, 0 0 50px #ccc, 0 0 60px #ccc, 0 0 70px #ccc;
            }
            to {
                text-shadow: 0 0 20px rgb(108, 238, 255), 0 0 30px aqua, 0 0 40px aqua, 0 0 50px aqua, 0 0 60px aqua, 0 0 70px aqua, 0 0 80px aqua;
            }
        }
        
        @keyframes slider {
            0% {
                background-image: url(../images/pexels-1.jpg);
            }
            25% {
                background-image: url(../images/pexels-4.jpg);
            }
            50% {
                background-image: url(../images/pexels-2.jpg);
            }
            80% {
                background-image: url(../images/pexels-3.jpg);
            }
        }
    </style>
</head>

<body>
    <section class="background">
        <div class="divmain">
            <div class="mask">
                <h1 class="glow">This is a slider</h1>
            </div>
        </div>
    </section>
</body>

</html>
Better Bee

Slider gambar CSS

//https://www.w3schools.com/howto/howto_js_slideshow.asp 
Shiny Shrimp

Slider gambar HTML CSS

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {box-sizing: border-box}
body {font-family: Verdana, sans-serif; margin:0}
.mySlides {display: none}
img {vertical-align: middle;}

/* Slideshow container */
.slideshow-container {
  max-width: 1000px;
  position: relative;
  margin: auto;
}

/* Next & previous buttons */
.prev, .next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  padding: 16px;
  margin-top: -22px;
  color: white;
  font-weight: bold;
  font-size: 18px;
  transition: 0.6s ease;
  border-radius: 0 3px 3px 0;
  user-select: none;
}

/* Position the "next button" to the right */
.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
  background-color: rgba(0,0,0,0.8);
}

/* Caption text */
.text {
  color: #f2f2f2;
  font-size: 15px;
  padding: 8px 12px;
  position: absolute;
  bottom: 8px;
  width: 100%;
  text-align: center;
}

/* Number text (1/3 etc) */
.numbertext {
  color: #f2f2f2;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}

/* The dots/bullets/indicators */
.dot {
  cursor: pointer;
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

.active, .dot:hover {
  background-color: #717171;
}

/* Fading animation */
.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 1.5s;
  animation-name: fade;
  animation-duration: 1.5s;
}

@-webkit-keyframes fade {
  from {opacity: .4} 
  to {opacity: 1}
}

@keyframes fade {
  from {opacity: .4} 
  to {opacity: 1}
}

/* On smaller screens, decrease text size */
@media only screen and (max-width: 300px) {
  .prev, .next,.text {font-size: 11px}
}
</style>
</head>
<body>

<div class="slideshow-container">

<div class="mySlides fade">
  <div class="numbertext">1 / 3</div>
  <img src="img url here" style="width:100%">
  <div class="text"></div>
</div>

<div class="mySlides fade">
  <div class="numbertext">2 / 3</div>
  <img src="img url here" style="width:100%">
  <div class="text"></div>
</div>

<div class="mySlides fade">
  <div class="numbertext">3 / 3</div>
  <img src="img url here" style="width:100%">
  <div class="text"></div>
</div>

<a class="prev" onclick="plusSlides(-1)">&#10094;</a>
<a class="next" onclick="plusSlides(1)">&#10095;</a>

</div>
<br>

<div style="text-align:center">
  <span class="dot" onclick="currentSlide(1)"></span> 
  <span class="dot" onclick="currentSlide(2)"></span> 
  <span class="dot" onclick="currentSlide(3)"></span> 
</div>

<script>
var slideIndex = 1;
showSlides(slideIndex);

function plusSlides(n) {
  showSlides(slideIndex += n);
}

function currentSlide(n) {
  showSlides(slideIndex = n);
}

function showSlides(n) {
  var i;
  var slides = document.getElementsByClassName("mySlides");
  var dots = document.getElementsByClassName("dot");
  if (n > slides.length) {slideIndex = 1}    
  if (n < 1) {slideIndex = slides.length}
  for (i = 0; i < slides.length; i++) {
      slides[i].style.display = "none";  
  }
  for (i = 0; i < dots.length; i++) {
      dots[i].className = dots[i].className.replace(" active", "");
  }
  slides[slideIndex-1].style.display = "block";  
  dots[slideIndex-1].className += " active";
}
</script>

</body>
</html> 
Thomas coder

Jawaban yang mirip dengan “Slider HTML CSS”

Pertanyaan yang mirip dengan “Slider HTML CSS”

Lebih banyak jawaban terkait untuk “Slider HTML CSS” di HTML

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya