@tolokoban/ui
Version:
React components with theme
35 lines (32 loc) • 695 B
CSS
* {
box-sizing: border-box;
}
b {
margin: 0 0.3em;
}
/**
* Aspect ratio
* Example: <div style="--custom-aspect-ratio=16/9">...</div>
*/
[style*="--custom-aspect-ratio"] > :first-child {
width: 100%;
}
[style*="--custom-aspect-ratio"] > img {
height: auto;
}
@supports (--custom: property) {
[style*="--custom-aspect-ratio"] {
position: relative;
}
[style*="--custom-aspect-ratio"]::before {
content: "";
display: block;
padding-bottom: calc(100% / (var(--custom-aspect-ratio)));
}
[style*="--custom-aspect-ratio"] > :first-child {
position: absolute;
top: 0;
left: 0;
height: 100%;
}
}