<div class="css-slider">
<input type="radio" name="slider-navigation" checked="checked" id="first-slide" />
<input type="radio" name="slider-navigation" id="second-slide" />
<input type="radio" name="slider-navigation" id="third-slide" />
<div class="css-slider-navigation">
<label class="css-slider-navigation-item" for="first-slide"></label>
<label class="css-slider-navigation-item" for="second-slide"></label>
<label class="css-slider-navigation-item" for="third-slide"></label>
</div>
<div class="css-slider-wrapper">
<div class="css-slider-inner">
<div id="actual-first-slide" class="css-slider-item" style="background-image: url(http://nathan-peixoto-web.yo.fr/stock-photos/01.jpg);">
<div class="css-slider-item-inner">
<div class="slide-title">
Hello
</div>
<div class="slide-subtitle">
How are you?
</div>
</div>
</div>
<div id="actual-second-slide" class="css-slider-item" style="background-image: url(http://nathan-peixoto-web.yo.fr/stock-photos/02.jpg);">
<div class="css-slider-item-inner">
<div class="slide-title">
Nice to meet you
</div>
<div class="slide-subtitle">
I'm a slider without JS.
</div>
</div>
</div>
<div id="actual-third-slide" class="css-slider-item" style="background-image: url(http://nathan-peixoto-web.yo.fr/stock-photos/03.jpg);">
<div class="css-slider-item-inner">
<div class="slide-title">
Feel free to use me
</div>
<div class="slide-subtitle">
Don't be shy
</div>
</div>
</div>
</div>
</div>
</div>
body{
margin: 0;
}
$slider-movement-duration: 500ms;
$step-wait: 250ms;
$slide-animation-duration: 500ms;
$animation-total-duration: $slider-movement-duration + $step-wait + $slide-animation-duration;
.css-slider{
position: relative;
width: 100vw;
height: 100vh;
.css-slider-navigation{
z-index: 2;
position: absolute;
top: 20px;
left: 50%;
transform: translateX(-50%) translateY(-50%);
.css-slider-navigation-item{
cursor: pointer;
position: relative;
width: 10px;
height: 10px;
border-radius: 50%;
background: black;
display: inline-block;
&:active,
&:hover,
&:focus{
background: gray;
}
}
}
@for $j from 1 to 10{
input[type=radio]:nth-of-type(#{$j}):checked{
~ .css-slider-navigation{
.css-slider-navigation-item:nth-child(#{$j}){
background: gray;
}
}
~ .css-slider-wrapper{
.css-slider-inner{
transform: translateX(- 100% * ($j - 1));
.css-slider-item:nth-child(#{$j}){
transition-delay: $animation-total-duration;
left: 0;
top: 0;
margin-right: 0;
width: 100%;
height: 100%;
.css-slider-item-inner{
*{
top: 0;
opacity: 1;
@for $k from 0 to 10{
&:nth-child(#{$k}){
transition-delay: $animation-total-duration + (100ms * ($k - 1));
transition-duration: 500ms - 100ms * ($k - 1);
}
}
}
}
}
}
}
}
}
.css-slider-wrapper{
z-index: 1;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: hidden;
.css-slider-inner{
position: relative;
white-space: nowrap;
height: 100%;
transform: translateX(0);
transition: transform $slider-movement-duration ease;
transition-delay: $slide-animation-duration + $step-wait;
font-size: 0;
text-shadow: 0 0 15px black;
.css-slider-item{
position: relative;
$space: 40px;
display: inline-block;
vertical-align: top;
font-size: initial;
color: white;
left: $space;
top: $space;
margin-right: 2 * $space;
width: calc(100% - 2 * #{$space});
transition-delay: 0;
height: calc(100% - 2 * #{$space});
background-size: cover;
background-position: center;
transition: margin-right 500ms ease, top 500ms ease, left 500ms ease, width 500ms ease, height 500ms ease, transform 500ms ease, opacity 500ms ease;
transition-duration: $slide-animation-duration;
.css-slider-item-inner{
position: absolute;
left: 0;
width: 100%;
text-align: center;
top: 50%;
transform: translateY(-50%);
*{
position: relative;
top: -50px;
opacity: 0;
transition: opacity 500ms ease, top 500ms ease;
@for $k from 0 to 10{
&:nth-child(#{$k}){
transition-delay: 100ms * ($k - 1);
transition-duration: 500ms - 100ms * ($k - 1);
}
}
}
}
}
}
}
}
.slide-title{
font-size: 42px;
font-family: "Open Sans";
font-weight: 100;
text-transform: uppercase;
}
.slide-subtitle{
font-size: 24px;
font-style: italic;
}
input[type=radio]{
display: none;
}
@keyframes fade{
0%{
opacity: 1;
}
50%{
opacity: 0;
}
100%{
opacity: 1;
}
}
View Compiled
This Pen doesn't use any external CSS resources.