Last active
January 12, 2018 15:52
-
-
Save vincentnavetat/01a3e5cfd1c56a10c34a34a949d13b62 to your computer and use it in GitHub Desktop.
Carousel component - Large screens styles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// maximum number of slides the carousel can have on large screens | |
$number-of-slides: 10; | |
.carousel { | |
max-width: 1236px; | |
margin-left: auto; | |
margin-right: auto; | |
padding-left: 48px; | |
padding-right: 48px; | |
position: relative; | |
} | |
.carousel__activator { | |
display: none; | |
} | |
.carousel__controls { | |
display: none; | |
align-items: center; | |
justify-content: space-between; | |
position: absolute; | |
top: 0; | |
right: 16px; | |
left: 16px; | |
bottom: 0; | |
&:first-of-type { | |
justify-content: flex-end; | |
} | |
&:last-of-type { | |
justify-content: flex-start; | |
} | |
} | |
.carousel__control { | |
cursor: pointer; | |
display: flex; | |
align-items: center; | |
background-color: #fff; | |
color: #3d414a; | |
border-radius: 100%; | |
box-shadow: 0 2px 10px 0 rgba(33,34,36,0.3); | |
font-size: 24px; | |
height: 48px; | |
justify-content: center; | |
transition: 0.3s all; | |
width: 48px; | |
z-index: 1; | |
&:hover { | |
transform: scale(1.05); | |
} | |
} | |
@for $i from 1 through $number-of-slides { | |
.carousel__activator:nth-of-type(#{$i}):checked | |
~ .carousel__controls:nth-of-type(#{$i}) { | |
display: flex; | |
} | |
.carousel__activator:nth-of-type(#{$i}):checked | |
~ .carousel__screen | |
.carousel__track { | |
transform: translateX(#{(1 - $i) * 100%}); | |
} | |
} | |
.carousel__screen { | |
overflow: hidden; | |
margin-left: -16px; | |
margin-right: -16px; | |
} | |
.carousel__track { | |
// font size 0 to remove space between the slides | |
// https://css-tricks.com/fighting-the-space-between-inline-block-elements/ | |
font-size: 0; | |
transition: all 0.3s ease 0s; | |
white-space: nowrap; | |
-webkit-overflow-scrolling: touch; | |
} | |
.carousel__item { | |
display: inline-flex; | |
padding-left: 16px; | |
padding-right: 16px; | |
vertical-align: top; | |
white-space: normal; | |
} | |
// desktop can have up to 5 items per slide | |
@for $i from 1 through 5 { | |
.carousel__item--desktop-in-#{$i} { | |
width: #{100% / $i}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment