I want to flip the card every time the content of my box changes i.e after every second or minute or hour or day passes.
I have tried applying transform and rotate properties directly to boxes but it is not working as it causes my text within the box to rotate 180 degrees rather than flipping the card.
.container {
background-color: #211D2E;
display: flex;
flex-direction: column;
align-items: center;
}
#midsec {
display: grid;
position: absolute;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: 1fr 3fr 1fr;
top: 104px;
width: 131vh;
height: 52%;
margin-left: auto;
margin-right: auto;
gap: 20px;
}
.container p {
color: #FFFEFF;
font-family: hat;
font-weight: 700;
font-size: xx-large;
letter-spacing: 2px;
position: relative;
display: grid;
grid-column-start: 2;
grid-column-end: 4;
align-items: center;
justify-content: center;
}
.container span {
font-family: hat;
color: hsl(237, 18%, 59%);
}
#stars {
margin-left: 5%;
max-width: 73%;
}
#hills {
max-width: 100%;
height: 34vh;
margin-top: 5%;
}
.top-box {
width: 100%;
display: grid;
background-color: #34364F;
border-radius: 11px;
align-items: center;
justify-content: center;
font-size: 21vh;
color: #FA5D86 !important;
letter-spacing: 3px;
}
.name {
display: grid;
align-items: center;
justify-content: center;
font-size: 20px;
font-weight: 600;
letter-spacing: 11px;
}
<div class="container">
<img src="images/bg-stars.svg" alt="none" id="stars">
<div id="midsec">
<p>We're launching soon</p>
<span class="name" style="grid-row: 3; grid-column: 1;">Days</span>
<span class="name" style=" grid-row: 3; grid-column: 2;">Hours</span>
<span class="name" style=" grid-row: 3; grid-column: 3;">Minutes</span>
<span class="name" style=" grid-row: 3; grid-column: 4;">Seconds</span>
<span class="top-box" id="days" style="grid-column: 1;"> </span>
<span class="top-box" id="hours" style="grid-column: 2;"></span>
<span class="top-box" id="mins" style="grid-column: 3;"></span>
<span class="top-box" id="seconds" style="grid-column: 4;"></span>
</div>
<img src="images/pattern-hills.svg" alt="none" id="hills">
</div>
2
Answers
transition
property in.top-box
:transition: transform 0.6s;
CSS
for the.flip
which will be added dynamically withJS
:script
to display timer and flip functionality:NOTE: Adjust my
code
according to your desired output. Happy coding!In order to create a flipping card effect which will update every second, minute, hour or day, you should use CSS Animations and JavaScript in order to update the content of box items.
I am listing down a method which you can use to implement this:
Now the CSS code is written below:
JavaScript
Note: You should do the basic manipulation from your side as per your requirements.
I hope you will find my response will resolve your query.