h1 Slideshow
h2 using cool 3d showcase effects
section.slideshow
ul.items
li.item
h3 First
div.img.first
h4 1
span Put your website layout / whatever here
li.item
h3 Second
div.img.second
h4 2
span Put your website layout / whatever here
li.item
h3 Third
div.img.third
h4 3
span Put your website layout / whatever here
li.item
h3 Fourth
div.img.fourth
h4 4
span Put your website layout / whatever here
div.nav
button.prev
button.next
View Compiled
body
background: hsl(0, 100, 60)
font-family: sans-serif
h1, h2
position: absolute
left: 50%
transform: translateX(-50%)
font-family: sans-serif
text-transform: uppercase
letter-spacing: 2px
h1
top: 24px
color: hsl(0, 0, 100)
font-size: 12px
h2
top: 44px
color: hsl(0, 0, 100)
font-size: 10px
opacity: 0.7
.slideshow
position: absolute
width: 650px
height: 350px
top: 150px
left: 50%
background: hsl(0, 0, 100)
border-radius: 4px
box-shadow: 0 3px 18px hsl(0, 100, 40)
transform: translateX(-50%)
.item
position: absolute
width: 100%
height: 100%
opacity: 0
transition: all 0.4s ease-in-out
perspective: 800px
h3
position: absolute
bottom: -6px
left: 15px
color: hsl(0, 0, 85)
font-size: 50px
font-weight: bold
text-transform: uppercase
letter-spacing: 2px
.img
position: absolute
width: 320px
height: 500px
bottom: -30px
right: 100px
border-radius: 3px
opacity: 0
transition: transform 0.4s ease-in-out
transform: rotateX(45deg) rotateZ(-30deg) translateY(0%)
h4
position: absolute
bottom: -16px
right: 0
opacity: 0.4
color: hsl(0, 0, 100)
font-size: 160px
span
position: absolute
top: 50%
left: 50%
color: hsl(0, 0, 100)
font-size: 14px
text-align: center
text-shadow: -1px 1px 1px hsl(0, 0, 30)
line-height: 20px
transform: translate(-50%, -50%)
.item.on
z-index: 1
opacity: 1
transition: all 0.4s ease-in-out
.img
opacity: 1
animation: on 0.6s ease-in-out
animation-fill-mode: forwards
.img.first
background: hsl(210, 80, 30)
box-shadow: -3px 3px hsl(210, 80, 20)
.img.second
background: hsl(30, 80, 70)
box-shadow: -3px 3px hsl(30, 80, 60)
.img.third
background: hsl(270, 60, 50)
box-shadow: -3px 3px hsl(270, 60, 40)
.img.fourth
background: hsl(170, 40, 30)
box-shadow: -3px 3px hsl(170, 40, 20)
.nav
z-index: 10
position: absolute
bottom: -15px
right: 20px
border-radius: 20px
box-shadow: 0 8px 18px hsl(0, 100, 40)
button
position: relative
display: block
float: left
width: 50px
height: 40px
background: hsl(0, 100, 60)
box-shadow: 0 0 0 3px hsl(0, 0, 100) inset
border: none
outline: none
cursor: pointer
&::before, &::after
position: absolute
content: ''
&::before
width: 16px
height: 2px
top: 19px
background: hsl(0, 0, 100)
&::after
width: 6px
height: 6px
top: 16px
border-top: 2px solid hsl(0, 0, 100)
button.next
margin-left: -3px
border-top-right-radius: 20px
border-bottom-right-radius: 20px
cursor: e-resize
&::before
left: 15px
&::after
left: 24px
border-right: 2px solid hsl(0, 0, 100)
transform: rotate(45deg)
button.prev
border-top-left-radius: 20px
border-bottom-left-radius: 20px
cursor: w-resize
&::before
right: 15px
&::after
right: 24px
border-left: 2px solid hsl(0, 0, 100)
transform: rotate(-45deg)
@keyframes on
from
opacity: 0
transform: rotateX(45deg) rotateZ(-30deg) translateY(20%)
to
transform: rotateX(45deg) rotateZ(-30deg) translateY(0%)
View Compiled
// Still one error in console when we click next on last element or previous on first element. It is trying to add 'on' class on an empty element right before we go back to first/last child. Im working on it but help is always appreciated :3
function init() {
first.classList.add('first', 'on');
last.classList.add('last');
}
function slide(target) {
var current = document.querySelector('.items .on'),
next = current.nextElementSibling,
prev = current.previousElementSibling;
current.classList.remove('on');
if (target.classList.contains('next') && current.classList.contains('last')) first.classList.add('on');
if (target.classList.contains('next')) next.classList.add('on');
if (target.classList.contains('prev') && current.classList.contains('first')) last.classList.add('on');
if (target.classList.contains('prev')) prev.classList.add('on');
}
var first = document.querySelector('.items li:first-child'),
last = document.querySelector('.items li:last-child');
window.onload = init;
document.body.onmouseup = function (event) {
var target = event.target || event.toElement;
if (target.tagName.toLowerCase() == 'button') slide(target);
};
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.