- is = [ //https://unsplash.com/@nicolehoneywill
- "https://images.unsplash.com/photo-1537886079430-486164575c54?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=4c747db3353a34b312d05786f47930d3&auto=format&fit=crop&w=600&q=60",
- "https://images.unsplash.com/photo-1537886194634-e6b923f92ff1?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=9eb2726071e58c1b0a430a75b1047525&auto=format&fit=crop&w=600&q=60",
- "https://images.unsplash.com/photo-1537886243959-0b504cf58aa2?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=1171ce40e6e68e663c3399a67a915913&auto=format&fit=crop&w=600&q=60",
- "https://images.unsplash.com/photo-1537886492139-052c27acbfee?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=664282a4bd8b8a69cc860420214df3e7&auto=format&fit=crop&w=600&q=60",
- "https://images.unsplash.com/photo-1537886464786-8a0d500b0da6?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=49984d393482456ea5484c3482cc52a9&auto=format&fit=crop&w=600&q=60"
- ]
.w
.ts
- n = 0
while ++n <= 5
input(type="radio",id=`c${n}`,name="ts",checked=n==1)
label.t(for=`c${n}`)
img(src=is[n-1])
View Compiled
body {
display:grid;
place-content:center;
min-height:100vh;
overflow:hidden;
}
.w {
width:50vmin;
height:80vmin;
}
.ts {
width:100%; height:100%;
position:relative;
--barH:10%;/*active zone height = 100% - barH*/
}
.t {
--w:20%;
display:block; width:var(--w); height:var(--barH);
position:absolute; bottom:0; left:var(--l);
transform-origin:top left;
}
.t img {
dislay:block; width:100%; height:100%;
object-fit:cover;
transform:scale(0.8);
}
[type="radio"] {
display:none;
}
:checked + label.t {
left:0; bottom:var(--barH);
height:calc(100% - var(--barH));
}
:checked + label.t img {
object-fit:contain;
}
/*
optional
*/
.ts {/*thumbnails bar*/
perspective:100px;
perspective-origin:center center;
transform-style:preserve-3d;
pointer-events:none;
}
.ts:after {/*the plate*/
content:"";
display:block; width:100%; height:15px;
position:absolute; bottom:0;
background:linear-gradient(transparent 20%, rgba(0,0,0,0.1));
transform:rotateX(90deg)scaleX(1.2);
transform-origin:bottom center;
}
:not(:checked) + .t {/*inactive labels*/
transform:translate3d(0, 0, -5px);
pointer-events:auto;
}
:not(:checked) + .t:hover {
transform:translate3d(0, -7px, -5px);
box-shadow:0 30px 30px -25px rgba(0,0,0,0.3);
cursor:pointer;
}
:not(:checked) + .t img {
transform:scale(0.9);/*create gaps*/
}
:checked + .t {/*active label*/
box-shadow:0 0 0 transparent;
animation:anim 2s 1;
} @keyframes anim {
from { transform:rotateY(6deg)rotateX(3deg) }
}
/*
transitions
*/
.t {/*active->inactive & hover->rest*/
transition:transform 0.5s, bottom 0.6s, left 0.6s, width 0.3s, box-shadow 1s;
}
.t:hover, :checked + .t {
transition:transform 0.5s, bottom 0.6s, left 0.6s, width 0.3s, box-shadow 0s;
}
const els = document.querySelectorAll("[type='radio']");
for (const el of els)
el.addEventListener("input", e => reorder(e.target, els));
reorder(els[0], els);
function reorder(targetEl, els) {
const nItems = els.length;
let processedUncheck = 0;
for (const el of els) {
const containerEl = el.nextElementSibling;
if (el === targetEl) {//checked radio
containerEl.style.setProperty("--w", "100%");
containerEl.style.setProperty("--l", "0");
}
else {//unchecked radios
containerEl.style.setProperty("--w", `${100/(nItems-1)}%`);
containerEl.style.setProperty("--l", `${processedUncheck * 100/(nItems-1)}%`);
processedUncheck += 1;
}
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.