<header class="header">
<img src="https://assets.twicpics.com/videos/demo-twicpics/logo-white.png" alt="TwicPics logo" />
</header>
<main>
<div
class="twic-w squared"
style="background-image:url('https://demo.twic.pics/v1/output=preview/image:cat_1x1.jpg');"
>
<img
data-twic-src="image:cat_1x1.jpg"
>
</div>
<div
class="twic-w portrait"
style="background-image:url('https://demo.twic.pics/v1/output=preview/image:cat_1x1.jpg');"
>
<img
data-twic-src="image:cat_1x1.jpg"
>
</div>
<div
class="twic-w landscape"
style="background-image:url('https://demo.twic.pics/v1/output=preview/image:cat_1x1.jpg');"
>
<img
data-twic-src="image:cat_1x1.jpg"
>
</div>
<div
class="twic-w squared contain"
style="background-image:url('https://demo.twic.pics/v1/contain=1000x1000/output=preview/image:cat_1x1.jpg');"
>
<img class="contain"
data-twic-src="image:cat_1x1.jpg"
src="https://demo.twic.pics/v1/output=preview/image:cat_1x1.jpg"
>
</div>
<div
class="twic-w portrait contain"
style="background-image:url('https://demo.twic.pics/v1/contain=667x1000/output=preview/image:cat_1x1.jpg');"
>
<img class="contain"
data-twic-src="image:cat_1x1.jpg"
>
</div>
<div
class="twic-w landscape contain"
style="background-image:url('https://demo.twic.pics/v1/contain=1000x667/output=preview/image:cat_1x1.jpg');"
>
<img class="contain"
data-twic-src="image:cat_1x1.jpg"
src="https://demo.twic.pics/v1/output=preview/image:cat_1x1.jpg"
>
</div>
</main>
<div>I Will Not CLS</div>
<!-- Installation of the TwicPics -->
<script src="https://demo.twic.pics/?v1" async defer></script>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Montserrat", sans-serif;
color: #454446;
}
div{
background-color : #1CFFA6;
}
main {
padding: 2em;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
align-items: center;
grid-gap: 1em;
}
img {
display: block;
object-fit: cover;
width: 100%;
height: 100%;
}
@mixin aspect-ratio($width, $height) {
position: relative;
overflow: hidden;
&:before {
display: block;
content: "";
width: 100%;
padding-top: ($height / $width) * 100%;
}
> img {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
}
.twic-w {
border: 5px solid red;
width: 100%;
background-size:cover;
background-repeat: no-repeat;
background-position: center;
overflow: hidden;
& img {
opacity:0;
transition-property: opacity;
will-change: opacity;
transition-delay: 0s;
transition-duration: 400ms;
transition-timing-function: ease;
&.twic-done{
opacity:1;
}
}
}
.contain {
object-fit: contain;
background-size:contain;
}
.squared{
@include aspect-ratio(1, 1);
}
.landscape{
@include aspect-ratio(3, 2);
}
.portrait{
@include aspect-ratio(2, 3);
}
.header {
display: flex;
justify-content: center;
align-items: center;
padding: 5px 0 8px 0;
background-color: #9002ff;
& img {
width: 140px;
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.