Pure CSS Image Slider
How do I make an pure css image slider?
Experimental, feel free to fork and improve! Please let me know how you've improved it though!. What is a pure css image slider? How do you make a pure css image slider? This script and codes were developed by Ken Lauguico on 22 December 2022, Thursday.
Pure CSS Image Slider - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Pure CSS Image Slider</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="title"> <h1> Pure CSS Image Slider! </h1>
</div>
<div class="slider"> <div class="slide"> <img src="http://placehold.it/600x300&text=Slide+1" /> </div> <div class="slide"> <img src="http://placehold.it/600x300&text=Slide+2" /> </div> <div class="slide"> <img src="http://placehold.it/600x300&text=Slide+3" /> </div> <div class="slide"> <img src="http://placehold.it/600x300&text=Slide+4" /> </div> <div class="slide"> <img src="http://placehold.it/600x300&text=Slide+5" /> </div>
</div> <script src="js/index.js"></script>
</body>
</html>
Pure CSS Image Slider - Script Codes CSS Codes
/*
VARIABLES
------------------------
Setting up variables to properly fit and style slider content.
------------------------*/
.slider { margin: auto; width: 600px; height: 300px; overflow: hidden; white-space: nowrap;
}
.slider .slide { overflow: hidden; display: inline-block; width: 600px;
}
.slider .slide img { float: right;
}
/*
KEYFRAMES + ANIMATION
---------------------
Some math to know exactly what percentage
each keyframe is based on slide # and duration.
---------------------*/
@-webkit-keyframes slide-1 { 20% { width: 600px; } 22%, 98% { width: 0; }
}
@-moz-keyframes slide-1 { 20% { width: 600px; } 22%, 98% { width: 0; }
}
@keyframes slide-1 { 20% { width: 600px; } 22%, 98% { width: 0; }
}
.slide:nth-child(1) { -webkit-animation: slide-1 30s infinite; -moz-animation: slide-1 30s infinite; animation: slide-1 30s infinite;
}
@-webkit-keyframes slide-2 { 40% { width: 600px; } 42%, 98% { width: 0; }
}
@-moz-keyframes slide-2 { 40% { width: 600px; } 42%, 98% { width: 0; }
}
@keyframes slide-2 { 40% { width: 600px; } 42%, 98% { width: 0; }
}
.slide:nth-child(2) { -webkit-animation: slide-2 30s infinite; -moz-animation: slide-2 30s infinite; animation: slide-2 30s infinite;
}
@-webkit-keyframes slide-3 { 60% { width: 600px; } 62%, 98% { width: 0; }
}
@-moz-keyframes slide-3 { 60% { width: 600px; } 62%, 98% { width: 0; }
}
@keyframes slide-3 { 60% { width: 600px; } 62%, 98% { width: 0; }
}
.slide:nth-child(3) { -webkit-animation: slide-3 30s infinite; -moz-animation: slide-3 30s infinite; animation: slide-3 30s infinite;
}
@-webkit-keyframes slide-4 { 80% { width: 600px; } 82%, 98% { width: 0; }
}
@-moz-keyframes slide-4 { 80% { width: 600px; } 82%, 98% { width: 0; }
}
@keyframes slide-4 { 80% { width: 600px; } 82%, 98% { width: 0; }
}
.slide:nth-child(4) { -webkit-animation: slide-4 30s infinite; -moz-animation: slide-4 30s infinite; animation: slide-4 30s infinite;
}
@-webkit-keyframes slide-5 { 100% { width: 600px; } 102%, 98% { width: 0; }
}
@-moz-keyframes slide-5 { 100% { width: 600px; } 102%, 98% { width: 0; }
}
@keyframes slide-5 { 100% { width: 600px; } 102%, 98% { width: 0; }
}
/*
PAGE STYLES
---------------
Styling unrelated to slider.
Yep, that's all for the slider!
---------------*/
.title { width: 100%; text-align: center;
}
Pure CSS Image Slider - Script Codes JS Codes
// Not today!
Developer | Ken Lauguico |
Username | kenlauguico |
Uploaded | December 22, 2022 |
Rating | 3 |
Size | 3,208 Kb |
Views | 34,408 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Flat Email Form | 3,415 Kb |
Animated Captions via data- Attribute | 2,502 Kb |
A Responsive Menu | 3,590 Kb |
Protoshow.js Demo | 1,984 Kb |
Fourground Logo | 3,072 Kb |
Simple Dot Loader | 2,272 Kb |
Force Counter | 2,732 Kb |
Just an animated underline | 2,229 Kb |
Typing Simulator | 2,910 Kb |
A Pen by Ken Lauguico | 4,517 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Geildanke typography | Fischaela | 3,249 Kb |
Awesome textarea | Ayoungh | 1,977 Kb |
Flower expansion | Sreucherand | 3,425 Kb |
Fading Navigation Bar | J-w-v | 2,805 Kb |
SVG Transform vs CSS Transform | AmeliaBR | 4,175 Kb |
Scifi-style Interative Form | Aaronchuo | 4,566 Kb |
Carousel Test | Sbirchall | 1,509 Kb |
Save for later... | Victorfreire | 1,359 Kb |
FreeCodeCamp - Simon Game | Ivhed | 8,481 Kb |
CSS Tooltips | Darylldoyle | 2,599 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!