Skip to content

Instantly share code, notes, and snippets.

@YuraKolesnikov
Created November 17, 2018 07:44
Show Gist options
  • Save YuraKolesnikov/aef4429056f4c919234259ac7d31bab2 to your computer and use it in GitHub Desktop.
Save YuraKolesnikov/aef4429056f4c919234259ac7d31bab2 to your computer and use it in GitHub Desktop.
Flex slider/container
<div class="slider">
<div class="item item-1">
<span class="item-title">Summer</span></div>
<div class="item item-2">
<span class="item-title">Is</span></div>
<div class="item item-3">
<span class="item-title">Very</span></div>
<div class="item item-4">
<span class="item-title">Cool</span></div>
</div>
.slider {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
width: 80vw;
margin: auto;
}
.item {
display: flex;
justify-content: center;
align-items: center;
height: 70vh;
flex-basis: 25%;
color: white;
text-transform: uppercase;
font-size: 2em;
transition: all .5s ease;
cursor: pointer;
position: relative;
}
.item:after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: block;
background-color: rgba(0, 0, 0, 0.5);
transition: all .5s ease;
}
.item .item-title {
z-index: 1000;
}
.item:hover {
flex-basis: 100%;
}
.item:hover:after {
background-color: rgba(0, 0, 0, 0.3);
}
.item-1 {
background: url('https://source.unsplash.com/random/700x1001');
background-position: center;
}
.item-2 {
background: url('https://source.unsplash.com/random/700x1002');
background-position: center;
}
.item-3 {
background: url('https://source.unsplash.com/random/700x1003');
background-position: center;
}
.item-4 {
background: url('https://source.unsplash.com/random/700x1004');
background-position: center;
}
@media (max-width: 768px) {
.slider {
height: 100vh;
width: 100vw;
flex-flow: column;
}
.item {
width: 100%;
}
.item:hover {
flex-grow: 30%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment