Files
blog/templates/shortcodes/carousel.html
2026-03-25 08:07:27 +01:00

127 lines
2.5 KiB
HTML

<ul class="carousel_{{ nth }}">
{{ body | safe }}
</ul>
<style>
.carousel_{{ nth }} {
width: 100%;
/* height: 300px; */
padding: 20px;
display: flex;
gap: 4vw;
overflow-x: scroll;
scroll-snap-type: x mandatory;
/* this will hide the scrollbar in mozilla based browsers */
overflow: -moz-scrollbars-none;
scrollbar-width: none;
/* this will hide the scrollbar in internet explorers */
-ms-overflow-style: none;
}
/* this will hide the scrollbar in webkit based browsers - safari, chrome, etc */
.carousel_{{ nth }} ul::-webkit-scrollbar {
width: 0 !important;
display: none;
}
.carousel_{{ nth }}>li {
list-style-type: none;
/* background-color: #eeeeee; */
/* border: 1px solid #dddddd; */
padding: 20px;
flex: 0 0 100%;
scroll-snap-align: center;
}
.carousel_{{ nth }}>li:nth-child(even) {
/* background-color: cyan; */
}
.carousel_{{ nth }}>li::after {
visibility: hidden;
}
.carousel_{{ nth }}::scroll-button(*) {
border: 0;
font-size: 2rem;
background: none;
color: white;
opacity: 0.7;
cursor: pointer;
}
.carousel_{{ nth }}::scroll-button(*):hover,
.carousel_{{ nth }}::scroll-button(*):focus {
opacity: 1;
}
.carousel_{{ nth }}::scroll-button(*):active {
translate: 1px 1px;
}
.carousel_{{ nth }}::scroll-button(*):disabled {
opacity: 0.2;
cursor: unset;
}
.carousel_{{ nth }}::scroll-button(left) {
content: "◄" / "Previous";
}
.carousel_{{ nth }}::scroll-button(right) {
content: "►" / "Next";
}
.carousel_{{ nth }} {
anchor-name: --my-carousel_{{ nth }};
}
.carousel_{{ nth }}::scroll-button(*) {
position: absolute;
position-anchor: --my-carousel_{{ nth }};
}
.carousel_{{ nth }}::scroll-button(left) {
right: calc(anchor(left) - 70px);
bottom: calc(anchor(bottom) + 10px);
}
.carousel_{{ nth }}::scroll-button(right) {
left: calc(anchor(right) - 70px);
bottom: calc(anchor(bottom) + 10px);
}
.carousel_{{ nth }} {
scroll-marker-group: after;
}
.carousel_{{ nth }}::scroll-marker-group {
position: absolute;
position-anchor: --my-carousel_{{ nth }};
bottom: calc(anchor(bottom) + 10px);
justify-self: anchor-center;
display: flex;
justify-content: center;
gap: 20px;
}
.carousel_{{ nth }}>li::scroll-marker {
content: attr(data-accName);
width: 16px;
height: 16px;
background-color: transparent;
border: 2px solid white;
border-radius: 50%;
overflow: hidden;
text-indent: 16px;
}
.carousel_{{ nth }}>li::scroll-marker:target-current {
background-color: white;
}
</style>