Just stumbled upon this amazing CSS-only carousel. Any hints on how I could make it responsive and display two carousels side by side?
Click here to view the carousel.
/* ***************************************************** */
/* SLIDER 1 */
/* ***************************************************** */
.carousel-wrapper {
border: 1px solid red;
background: red;
position: relative;
}
.carousel-wrapper .carousel-item {
border: 3px solid blue;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
padding: 0px;
opacity: 0;
transition: all 0.5s ease-in-out;
}
.carousel-wrapper .carousel-item .arrow {
position: absolute;
top: 0;
display: block;
width: 100px;
height: 80vh;
-webkit-tap-highlight-color: transparent;
background: url("../arrow.png") 50% 50%/20px no-repeat;
}
.carousel-wrapper .carousel-item .arrow.arrow-prev {
left: 0;
}
.carousel-wrapper .carousel-item .arrow.arrow-next {
right: 0;
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
.carousel-wrapper .carousel-item.light {
color: white;
}
.carousel-wrapper .carousel-item.light .arrow {
background: url("../arrow.png") 50% 50%/20px no-repeat;
}
.carousel-wrapper [id^="target-item"] {
display: none;
}
.carousel-wrapper .item-1 {
border: 5px solid yellow;
z-index: 2;
opacity: 1;
background-color: #FFF;
}
.carousel-wrapper .item-2 {
background-color: #FFF;
}
.carousel-wrapper .item-3 {
background: url("../blurry.jpg") no-repeat;
background-size: cover;
}
.carousel-wrapper *:target ~ .item-1 {
opacity: 0;
}
.carousel-wrapper #target-item-1:target ~ .item-1 {
border: 5px solid purple;
opacity: 1;
}
.carousel-wrapper #target-item-2:target ~ .item-2, .carousel-wrapper #target-item-3:target ~ .item-3 {
z-index: 3;
opacity: 1;
}
<div class="carousel-wrapper">
<span id="target-item-1"></span>
<span id="target-item-2"></span>
<span id="target-item-3"></span>
<div class="carousel-item item-1">
<p><br />x<br />x<br />x<br /></p>
<a class="arrow arrow-prev" href="#target-item-3"></a>
<a class="arrow arrow-next" href="#target-item-2"></a>
</div>
<div class="carousel-item item-2 light">
<p><br />x<br />x<br />x<br /></p>
<a class="arrow arrow-prev" href="#target-item-1"></a>
<a class="arrow arrow-next" href="#target-item-3"></a>
</div>
<div class="carousel-item item-3">
<p><br />x<br />x<br />x<br /></p>
<a class="arrow arrow-prev" href="#target-item-2"></a>
<a class="arrow arrow-next" href="#target-item-1"></a>
</div>
</div>
Original source:
One issue is that the height of the carousel cannot be defined (I plan to use it with 100vw pictures in place of placeholder text).
Thanks a lot, Matthias