html image slider
CSS
* {box-sizing:border-box}
/* Slideshow container */
.slideshow-container {
max-width: 1000px;
position:
relative;
margin: auto;
}
/* Hide the images by default */
.mySlides {
display: none;
}
/* Next & previous buttons */
.prev, .next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
margin-top: -22px;
padding: 16px;
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}
} <!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_nature_wide.jpg" style="width:100%">
<div class="text">Caption Text</div>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<img src="img_snow_wide.jpg" style="width:100%">
<div class="text">Caption Two</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="img_mountains_wide.jpg" style="width:100%">
<div class="text">Caption Three</div>
</div>
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</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>
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {slideIndex
= 1}
slides[slideIndex-1].style.display = "block";
setTimeout(showSlides, 2000); // Change image every 2
seconds
} var slideIndex = 1;
showSlides(slideIndex);
// Next/previous controls
function plusSlides(n)
{
showSlides(slideIndex += n);
}
// Thumbnail image controls
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";
}
Also in CSS:
- Title
- how to remove gap between divs
- Category
- CSS
- Title
- react native tutorial
- Category
- CSS
- Title
- css two attribute selector
- Category
- CSS
- Title
- scss @mixin base
- Category
- CSS
- Title
- center vertically and horizontally css
- Category
- CSS
- Title
- link css file in html
- Category
- CSS
- Title
- hegith specific css in media query
- Category
- CSS
- Title
- html font white text with black border
- Category
- CSS
- Title
- IE support stackover flow css
- Category
- CSS
- Title
- grid-template-areas css
- Category
- CSS
- Title
- javascript add inline style css var
- Category
- CSS
- Title
- hwo to use flexbox to make a nav bar
- Category
- CSS
- Title
- css style scrollbar
- Category
- CSS
- Title
- css font-size
- Category
- CSS
- Title
- css font size
- Category
- CSS
- Title
- animation shorthand css
- Category
- CSS
- Title
- make image darker in css
- Category
- CSS
- Title
- css rotate 90 deg
- Category
- CSS
- Title
- css vertical center
- Category
- CSS
- Title
- bootstrap.min.css
- Category
- CSS
- Title
- justify text csss
- Category
- CSS
- Title
- media querycss
- Category
- CSS
- Title
- changong text color css
- Category
- CSS
- Title
- center page css
- Category
- CSS
- Title
- css flex property
- Category
- CSS
- Title
- add css file to html
- Category
- CSS
- Title
- nth child css
- Category
- CSS
- Title
- css all children of type
- Category
- CSS
- Title
- material design css
- Category
- CSS
- Title
- difference between class and id in html css
- Category
- CSS
- Title
- fontawesome cdn
- Category
- CSS
- Title
- convert sass to css
- Category
- CSS
- Title
- css grid repeat
- Category
- CSS
- Title
- z-index max value
- Category
- CSS
- Title
- tachyons css
- Category
- CSS
- Title
- how to stilize title property css
- Category
- CSS
- Title
- Are HTML and Css programming languages?
- Category
- CSS
- Title
- adding background image css
- Category
- CSS
- Title
- background color css
- Category
- CSS
- Title
- how to slide text to the right in css
- Category
- CSS
- Title
- dotted line css
- Category
- CSS
- Title
- stop the client from scrolling
- Category
- CSS
- Title
- how to center text in css
- Category
- CSS
- Title
- bootsrap buttons
- Category
- CSS
- Title
- git stop merge
- Category
- CSS
- Title
- css circle
- Category
- CSS
- Title
- css disable user interaction
- Category
- CSS
- Title
- background gradient vertical css
- Category
- CSS
- Title
- css transition on hover
- Category
- CSS
- Title
- css distance between text and input box
- Category
- CSS
- Title
- sketchup make
- Category
- CSS
- Title
- bootstrap 4 material icon vertical align
- Category
- CSS
- Title
- font roboto css
- Category
- CSS
- Title
- css browser prefixes
- Category
- CSS
- Title
- background-image: image css
- Category
- CSS
- Title
- import css
- Category
- CSS
- Title
- custom scrollbar
- Category
- CSS
- Title
- count no. of ways to partition in k subsets
- Category
- CSS
- Title
- css onclick change color
- Category
- CSS
- Title
- css grid center elements inside div
- Category
- CSS
- Title
- make text unselectable css
- Category
- CSS
- Title
- center ul
- Category
- CSS
- Title
- rel css
- Category
- CSS
- Title
- update npm
- Category
- CSS
- Title
- kotlin string to int
- Category
- CSS
- Title
- gcd
- Category
- CSS
- Title
- css z index
- Category
- CSS
- Title
- css url do not change color of visited links
- Category
- CSS
- Title
- link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"
- Category
- CSS
- Title
- css keyframes
- Category
- CSS
- Title
- css selenium
- Category
- CSS
- Title
- svg tailwind
- Category
- CSS
- Title
- kotlin exit app
- Category
- CSS
- Title
- put an border around an text in css
- Category
- CSS
- Title
- align center css
- Category
- CSS
- Title
- how to make a dotted hr in css
- Category
- CSS
- Title
- using divs instead of table
- Category
- CSS
- Title
- open sublime text 3 from terminal mac
- Category
- CSS
- Title
- css background color transition
- Category
- CSS
- Title
- keep aspect ratio of image css
- Category
- CSS
- Title
- background color css rgb
- Category
- CSS
- Title
- do some css using js on selector
- Category
- CSS
- Title
- gradient over image css
- Category
- CSS
- Title
- how to change the background color in css
- Category
- CSS
- Title
- remove html scroll bar
- Category
- CSS
- Title
- css thinner hr
- Category
- CSS
- Title
- How to find the key of the largest value hash?
- Category
- CSS
- Title
- css semantic ui react specify size of image
- Category
- CSS
- Title
- npm 'cross-env' is not recognized as an internal or external command
- Category
- CSS
- Title
- comment out css inline
- Category
- CSS
- Title
- how to set border length in css without div
- Category
- CSS
- Title
- css transparent background color
- Category
- CSS
- Title
- neomorphic box
- Category
- CSS
- Title
- id in css
- Category
- CSS
- Title
- how to give a div placeholder text
- Category
- CSS
- Title
- css transform transition
- Category
- CSS
- Title
- css border style
- Category
- CSS
- Title
- margin css
- Category
- CSS
- Title
- generate random grid in css
- Category
- CSS
- Title
- dashed lin in css
- Category
- CSS