The content on this website, including videos and code examples, is for educational purposes only. All demonstrations and designs are fictional and created to illustrate coding techniques. Any resemblance to existing websites or brands is purely coincidental.
The creators and administrators of this website do not claim ownership or affiliation with any existing websites or companies. Users are encouraged to use the information responsibly for learning purposes. Liability for any misuse of the content provided is not accepted.
Below is the html code for this video.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flowers on Cake</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="cake">
<div class="flower">
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
</div>
<div class="flower">
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
</div>
<div class="flower">
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
</div>
<div class="cake-layer top-layer"></div>
<div class="cake-layer middle-layer"></div>
<div class="cake-layer bottom-layer"></div>
</div>
</div>
</body>
</html>
Below is the css code for this video.
style.css
* {
margin: 0;
padding: 0;
}
body {
display: flex;
height: 100vh;
width: 100%;
background: #004225;
justify-content: center;
align-items: center;
}
.container {
position: relative;
height: 45vmin;
width: 50vmin;
animation: cakeCompleteAnim 3s 5s ease forwards;
}
@keyframes cakeCompleteAnim {
0%, 50%, 100% {
transform: scale(1);
}
24%, 26%, 74%, 76% {
transform: scale(1.5);
}
}
.cake {
display: flex;
justify-content: center;
}
.flower {
position: absolute;
height: 10vmin;
width: 14.4vmin;
z-index: 3;
}
.flower:nth-child(1) {
opacity: 0;
animation: topFlowerAnim 1s 4s linear forwards;
}
@keyframes topFlowerAnim {
0% {
opacity: 0;
top: -100vmin;
}
100% {
opacity: 1;
top: 1vmin;
}
}
.flower:nth-child(2) {
left: 21vmin;
opacity: 0;
animation: middleFlowerAnim 1s 2.5s linear forwards;
}
@keyframes middleFlowerAnim {
0% {
opacity: 0;
top: -100vmin;
}
100% {
opacity: 1;
top: 9vmin;
}
}
.flower:nth-child(3) {
left: 15vmin;
opacity: 0;
animation: bottomFlowerAnim 1s 1s linear forwards;
}
@keyframes bottomFlowerAnim {
0% {
opacity: 0;
top: -100vmin;
}
100% {
opacity: 1;
top: 19vmin;
}
}
.flower .petal {
position: absolute;
bottom: 0;
height: 4vmin;
width: 4vmin;
background: #f7b3cd;
border: 0.4vmin solid #ff007f;
}
.flower .petal:nth-child(1) {
left: 4vmin;
border-radius: 0 50%;
z-index: 1;
}
.flower .petal:nth-child(2) {
left: 5vmin;
bottom: 1vmin;
border-radius: 0 50%;
transform: rotate(20deg);
}
.flower .petal:nth-child(3) {
left: 6.5vmin;
bottom: 0.5vmin;
border-radius: 0 50%;
z-index: 1;
transform: rotate(45deg);
}
.flower .petal:nth-child(4) {
bottom: 1vmin;
right: 2vmin;
border-radius: 50% 0;
transform: rotate(-20deg);
}
.flower .petal:nth-child(5) {
right: 1vmin;
border-radius: 50% 0;
}
.cake-layer {
position: absolute;
background: #f87b90;
border: 0.4vmin solid #c83f49;
border-radius: 1% 1% 50% 50%/1% 1% 40% 40%;
transform: rotateX(35deg);
margin: auto;
}
.cake-layer::before {
content: "";
position: absolute;
left: -0.4vmin;
background: #f87b90;
border: 0.4vmin solid #c83f49;
border-radius: 50%;
}
.bottom-layer {
height: 20vmin;
width: 36vmin;
opacity: 0;
animation: bottomLayerAnim 1s linear forwards;
}
@keyframes bottomLayerAnim {
0% {
opacity: 0;
bottom: 100vmin;
}
100% {
opacity: 1;
bottom: 0;
}
}
.bottom-layer::before {
height: 10vmin;
width: 36vmin;
opacity: 0;
animation: bottomBeforeLayerAnim 1s 0.5s linear forwards;
}
@keyframes bottomBeforeLayerAnim {
0% {
opacity: 0;
top: -100vmin;
}
100% {
opacity: 1;
top: -5vmin;
}
}
.middle-layer {
height: 13.33vmin;
width: 24vmin;
z-index: 1;
opacity: 0;
animation: middleLayerAnim 1s 1.5s linear forwards;
}
@keyframes middleLayerAnim {
0% {
opacity: 0;
bottom: 100vmin;
}
100% {
opacity: 1;
bottom: 16vmin;
}
}
.middle-layer::before {
height: 10vmin;
width: 24vmin;
opacity: 0;
animation: middleBeforeLayerAnim 1s 2s linear forwards;
}
@keyframes middleBeforeLayerAnim {
0% {
opacity: 0;
top: -100vmin;
}
100% {
opacity: 1;
top: -5vmin;
}
}
.top-layer {
height: 8vmin;
width: 14.4vmin;
z-index: 2;
opacity: 0;
animation: topLayerAnim 1s 3s linear forwards;
}
@keyframes topLayerAnim {
0% {
opacity: 0;
bottom: 100vmin;
}
100% {
opacity: 1;
bottom: 26vmin;
}
}
.top-layer::before {
height: 5.725vmin;
width: 14.4vmin;
opacity: 0;
animation: topBeforeLayerAnim 1s 3.5s linear forwards;
}
@keyframes topBeforeLayerAnim {
0% {
opacity: 0;
top: -100vmin;
}
100% {
opacity: 1;
top: -4vmin;
}
}
Thanks for visiting