Skip to content

Instantly share code, notes, and snippets.

@wplit
Created December 28, 2019 02:06
Show Gist options
  • Select an option

  • Save wplit/386454c45d10819453547c95780520ae to your computer and use it in GitHub Desktop.

Select an option

Save wplit/386454c45d10819453547c95780520ae to your computer and use it in GitHub Desktop.
Carousel/Slider from WordPress Gallery using Flickity (update CSS)
.gallery-carousel {
display: block;
margin-bottom: 1em;
}
.gallery-carousel:not(.columns-1) .blocks-gallery-item:last-child {
margin-right: 16px;
}
.gallery-carousel .blocks-gallery-item {
height: 200px;
}
.gallery-carousel .flickity-viewport {
width: 100%;
}
@media (min-width: 600px) {
.gallery-carousel.columns-3 .blocks-gallery-item:nth-of-type(3n),
.gallery-carousel.columns-4 .blocks-gallery-item:nth-of-type(4n),
.gallery-carousel.columns-5 .blocks-gallery-item:nth-of-type(5n),
.gallery-carousel.columns-6 .blocks-gallery-item:nth-of-type(6n),
.gallery-carousel.columns-7 .blocks-gallery-item:nth-of-type(7n),
.gallery-carousel.columns-8 .blocks-gallery-item:nth-of-type(8n) {
margin-right: 16px;
}
}
.gallery-carousel .flickity-prev-next-button.previous {
left: -60px;
}
.gallery-carousel .flickity-prev-next-button.next {
right: -60px;
}
@media only screen and (max-width: 768px) {
.gallery-carousel.columns-1 .blocks-gallery-item {
width: 50%;
}
.gallery-carousel .flickity-prev-next-button.previous,
.gallery-carousel .flickity-prev-next-button.next {
display: none;
}
}
@media only screen and (max-width: 480px) {
.gallery-carousel.columns-1 .blocks-gallery-item {
width: 100%;
}
.gallery-carousel.columns-1 .blocks-gallery-item:nth-of-type(1n) {
margin-right: 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment