CSS Only Envelope reveal invitation
by dhavaljani
HTML
<div class="envelope-container">
<div class="envelope">
<div class="top-flap"></div>
<div class="letter">
<img src="https://assets.ppassets.com/p-4z7unbMGB16SwkA44oJ5mC/flyer/paper_static/base" alt="Reyansh's Janoi Invitation" class="invitation-image">
</div>
<div class="bottom-flap"></div>
</div>
</div>
CSS
/* General Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f5f5f5;
}
/* Envelope Container */
.envelope-container {
position: relative;
width: 400px;
height: 300px;
}
/* Envelope */
.envelope {
position: relative;
width: 100%;
height: 100%;
}
/* Top Flap */
.top-flap {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 50%;
background-color: #d4a76a;
transform-origin: top center;
transition: transform 1s ease-in-out;
}
/* Bottom Flap */
.bottom-flap {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 50%;
background-color: #e8c093;
}
/* Letter (Invitation) */
.letter {
position: absolute;
top: calc(50% - 10px);
left: calc(50% - 150px);
width: calc(100% - 40px);
height: auto; /* Let the image determine the height */
}
.invitation-image {
width: auto;
}