Logo expanding effect
WIP
by katalin_2003
HTML
<form action="" method="POST">
<div class="card-container">
<div class="color-square square-1-1"></div>
<div class="cover-square square-1-2"></div>
<div class="color-square square-2-1"></div>
<div class="cover-square square-2-2"></div>
<div class="bi-form">
<input type="text" class="bi-email" name="bi-email" value="[email protected]">
<button class="bi-submit">SE CONNECTER</button>
</div>
</div>
</form>
CSS
* {
box-sizing: border-box;
}
body {
margin: 0px;
padding: 0px;
background-color: #303030;
padding-top: 2em;
}
.card-container {
position: relative;
width: 138px;
height: 138px;
margin: 0 auto;
background-color: #11ffee00;
transition: width 1s ease,
height 1s ease;
cursor: pointer;
}
.color-square {
position: absolute;
width: 100px;
height: 100px;
}
.cover-square {
position: absolute;
width: 65px; /* Not 64px so the back square won't "bleed" */
height: 65px; /* Not 64px so the back square won't "bleed" */
background-color: #303030;
}
.square-1-1 {
background-color: #74b94e;
top: 0px;
left: 0px;
}
.square-2-1 {
background-color: #d9dc3c;
bottom: 2px;
right: 2px;
}
.square-1-2 {
top: 36px;
left: 36px;
}
.square-2-2 {
bottom: 38px;
right: 38px;
}
.bi-form {
opacity: 0;
pointer-events: none;
/* 1.8s */
transition: opacity 1.8s ease;
}
.bi-email,
.bi-submit {
padding: 0.4em 0em 0.4em 0em;
}
.bi-email {
align-self: stretch;
margin-bottom: 1.8em;
text-align: center;
border: 1px solid #cccccc;
border-radius: 3px;
padding: 9px 20px;
}
.bi-email:focus {
outline: none;
}
.bi-submit {
width: 60%;
cursor: pointer;
background-color: #008c3c;
color: #ffffff;
border: 0px;
border-radius: 30px;
padding: 16px 30px;
}
.card-container-expand {
width: 600px;
height: 400px;
}
.bi-form-expand {
opacity: 1;
position: absolute;
width: 280px;
height: 6em;
visibility: visible;
display: flex;
flex-direction: column;
align-content: space-between;
align-items: center;
justify-content: center;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
margin: auto;
pointer-events: revert;
}
JavaScript
const cardContainer = document.getElementsByClassName('card-container')[0];
const biForm = document.getElementsByClassName('bi-form')[0];
cardContainer.addEventListener('click', function() {
this.classList.add('card-container-expand');
biForm.classList.add('bi-form-expand');
}, {once: true});