今天是我的生日,我想做一张生日许愿动态图来庆祝!<html> <head> <title>生日许愿动态图&l
今天是我的生日,我想做一张生日许愿动态图来庆祝!
<html>
<head>
<title>生日许愿动态图</title>
<style>
.cake {
position: relative;
width: 100px;
height: 120px;
margin: 0 auto;
background-color: white;
border-radius: 0 0 80px 80px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
z-index: 2;
}
.cake:before {
content: "";
position: absolute;
bottom: 0;
left: 15px;
width: 70px;
height: 70px;
background-color: white;
border-radius: 50%;
box-shadow: -5px -5px 20px rgba(0, 0, 0, 0.1);
z-index: 1;
}
.candle {
position: absolute;
top: 20px;
right: 20px;
width: 20px;
height: 60px;
background-color: yellow;
border-radius: 10px;
box-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
animation: blink 1s infinite;
z-index: 3;
}
@keyframes blink {
50% {
opacity: 0.5;
}
}
</style>
</head>
<body>
<div class="cake"></div>
<div class="candle"></div>
<script>
function makeWish() {
alert("生日快乐!");
}
document.querySelector(".candle").addEventListener("click", makeWish);
</script>
</body>
</html>
上面是HTML代码,可以在浏览器中运行,显示一张蛋糕和一支蜡烛,蜡烛会闪烁,点击蜡烛可以许愿,当然,这只是一个示例,你可以根据自己的需要和喜好来设计和实现更有趣、更丰富的生日许愿动态图。
粉丝
0
关注
0
收藏
0