gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
a css html animated cake
- User
a css html animated cake
- Assistant
a css html animated cake
Creating an animated cake using HTML and CSS can be a fun project! Below, you'll find a basic example of a simple cake design with animations using CSS.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Animated Cake</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="cake">
<div class="layer layer-1"></div>
<div class="layer layer-2"></div>
<div class="layer layer-3"></div>
<div class="candles">
<div class="candle"></div>
<div class="candle"></div>
<div class="candle"></div>
<div class="flame"></div>
</div>
</div>
</body>
</html>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f3f4f6;
margin: 0;
}
.cake {
position: relative;
width: 200px;
height: 150px;
}
.layer {
width: 100%;
border-radius: 15px;
position: absolute;
left: 0; bottom: 0;
}
.layer-1 {
height: 50px;
background-color: #ffcccb; /* Pink layer */
animation: wiggle 1s infinite;
}
.layer-2 {
height: 50px;
background-color: #ffcc99; /* Yellow layer */
bottom: 50px;
}
.layer-3 {
height: 50px;
background-color: #99ccff; /* Blue layer */
bottom: 100px;
}
.candles {
position: absolute;
top: -10px;
display: flex;
justify-content: space-between;
width: 60px;
left: 50%;
transform: translateX(-50%);
}
.candle {
width: 10px;
height: 40px;
background-color: #f7c6c7;
border: 1px solid #888;
border-radius: 5px;
position: relative;
}
.flame {
position: absolute;
top: -10px;
left: 50%;
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 12px solid yellow;
transform: translateX(-50%);
animation: flicker 0.5s infinite alternate;
}
@keyframes wiggle {
0% { transform: rotate(0deg); }
50% { transform: rotate(2deg); }
100% { transform: rotate(0deg); }
}
@keyframes flicker {
0% { opacity: 1; transform: translateY(0); }
100% { opacity: 0.5; transform: translateY(-2px); }
}
@keyframes wiggle.@keyframes flicker.You can customize the appearance and animations further by tweaking the CSS styles, adding more layers, or changing colors. Just copy the HTML and CSS code into your HTML document, and you'll have an animated cake!