Responsive Retina-ready Slider/Carousel In jQuery
File Size: | 11.2 KB |
---|---|
Views Total: | 5469 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
This is a small slider jQuery plugin to create a responsive, mobile-friendly, retina-ready, full-screen content slider/carousel from semantic HTML markup.
Licensed under the Apache License, Version 2.0.
How to use it:
1. Insert slides together with next/prev navigation controls into the HTML page.
<article class="slider"> <section class="slide"> <img src="img/1.jpg" alt=""> <div class="slide-content"> <p class="slide-title">Slide 1</p> </div> </section> <section class="slide"> <img src="img/2.jpg" alt=""> <div class="slide-content"> <p class="slide-title">Slide 2</p> </div> </section> <section class="slide"> <img src="img/3.jpg" alt=""> <div class="slide-content"> <p class="slide-title">Slide 3</p> </div> </section> <nav class="slider-nav"> <span class="prev-slide"></span> <span class="next-slide"></span> </nav> </article>
2. Load both jQuery JavaScript library and the slider.js
script in the document.
<script src="/path/to/jquery.min.js"></script> <script src="/path/to/slider.js"></script>
3. The basic styling of the carousel/slider.
.slider { position: relative; width: 100%; height: 100%; overflow: hidden; background-color: #555; } .slide { position: absolute; top: 0; left: 0; display: none; width: 100%; height: 100%; overflow: hidden; } .slide img { position: absolute; top: 0; left: 0; display: block; width: 100%; height: 100%; cursor: default; } .slide-content { position: absolute; bottom: 20%; width: 100%; text-align: center; color: #fff; -webkit-text-shadow: 0 2px 5px rgba(0, 0, 0, 0.6), 0 0 5px rgba(0, 0, 0, 0.5); -moz-text-shadow: 0 2px 5px rgba(0, 0, 0, 0.6), 0 0 5px rgba(0, 0, 0, 0.5); text-shadow: 0 2px 5px rgba(0, 0, 0, 0.6), 0 0 5px rgba(0, 0, 0, 0.5); } .slide-title { font-size: 10vw; } @media screen and (max-width: 61.25em) { .slider { max-height: 57.95918367vw; } } @media screen and (min-height: 61.25em) { .slider { max-height: 57.95918367vw; } }
4. The CSS for the navigation controls.
.next-slide, .prev-slide { position: absolute; display: inline-block; width: 3.125em; height: 3.125em; line-height: 3.125; margin: 0; border: .125em solid white; backface-visibility: hidden; background-color: rgba(0, 0, 0, 0.3); color: white; overflow: hidden; cursor: pointer; z-index: 20; -webkit-transition: all .3s ease-in-out 0s; -moz-transition: all .3s ease-in-out 0s; -o-transition: all .3s ease-in-out 0s; transition: all .3s ease-in-out 0s; -webkit-user-select: none; user-select: none; } .prev-slide { left: 2%; } .next-slide { right: 2%; } .next-slide:hover, .prev-slide:hover { background-color: rgba(0, 0, 0, 0.6); } .next-slide::before, .prev-slide::before { position: absolute; top: 33%; display: inline-block; width: .8125em; height: .8125em; content: ""; border-left: .25em solid white; border-top: .25em solid white; backface-visibility: hidden; } .prev-slide::before { -webkit-transform: rotate(-45deg); -moz-transform: rotate(-45deg); -ms-transform: rotate(-45deg); -o-transform: rotate(-45deg); transform: rotate(-45deg); right: 25%; } .next-slide::before { -webkit-transform: rotate(135deg); -moz-transform: rotate(135deg); -ms-transform: rotate(135deg); -o-transform: rotate(135deg); transform: rotate(135deg); left: 25%; } @media screen and (max-width: 42.5em) { .next-slide, .prev-slide { display: none; } }
Changelog:
2020-12-07
- CSS Updated
This awesome jQuery plugin is developed by jacobxperez. For more Advanced Usages, please check the demo page or visit the official website.