視頻
視頻地址:https://www.bilibili.com/video/BV1v54y1t7zn
十分鐘實作元旦祝福影片,CSS+JavaScript實作節日祝福影片,祝大家元旦快樂
視頻已同步到我的B站賬號歡迎大家關注,
https://space.bilibili.com/563010186
參考代碼
HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>元旦快樂:公眾號AlbertYang</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p>
<div class="box">
<dic class="circle">
<div class="text">
<span style="--x:0">元</span>
<span style="--x:1">旦</span>
<br />
<span style="--x:2">快</span>
<span style="--x:3">樂</span>
</div>
</dic>
</div>
</p>
<script>
const bubbles = () => {
let count = 300;
let p = document.querySelector("p");
for (let i = 0; i < count; i++) {
let bubble = document.createElement('i');
let x = Math.floor(Math.random() * window.innerWidth);
y = Math.floor(Math.random() * window.innerHeight);
let size = Math.random() * 60;
bubble.style.left = x + 'px';
bubble.style.top = y + 'px';
bubble.style.width = size + 'px';
bubble.style.height = size + 'px';
bubble.style.animationDuration = 5 + size + 's';
bubble.style.animationDelay = -size + 's';
p.appendChild(bubble);
}
}
bubbles()
</script>
</body>
</html>
CSS:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
overflow: hidden;
}
p {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #f1f1f1;
}
p .box {
position: absolute;
width: 450px;
height: 450px;
}
p .box .circle {
position: relative;
width: 100%;
height: 100%;
background: linear-gradient(135deg, #fff, #e4e3e8);
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
}
p .box .circle::before {
content: "";
position: absolute;
left: 5px;
top: 5px;
right: 5px;
bottom: 5px;
background: linear-gradient(315deg, #fff, #e4e3e8);
border-radius: 50%;
z-index: 1;
}
p .text {
position: absolute;
font-size: 6em;
color: #ff2a2a;
z-index: 2;
}
p .text span {
display: inline-block;
animation: blink 3s 2s infinite;
animation-delay: calc(var(--x) * 0.5s);
}
p i {
position: absolute;
background: #FF2A2A;
border-radius: 50%;
animation: animate linear infinite;
}
p i:nth-child(even) {
background: transparent;
border: 1px solid #FF2A2A;
}
@keyframes animate {
0% {
transform: translateY(0);
opacity: 0;
filter: hue-rotate(0deg);
}
10%,
90% {
opacity: 1;
}
100% {
transform: translateY(-3000%);
opacity: 0;
filter: hue-rotate(36000deg);
}
}
@keyframes blink {
0% {
transform: scale(0);
opacity: 0;
filter: hue-rotate(0deg);
}
30%,
50%,
80% {
transform: scale(1.3);
opacity: 1;
}
100% {
transform: scale(0);
opacity: 0;
filter: hue-rotate(3600deg);
}
}

今天的學習就到這里了,由于本人能力和知識有限,如果有寫的不對的地方,還請各位大佬批評指正,如果想繼續學習提高,歡迎關注我,每天進步一點點,就是領先的開始,加油,如果覺得本文對你有幫助的話,歡迎轉發,評論,點贊!!!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/243601.html
標籤:其他
上一篇:javaweb從入門到精通實戰——JSP環境配置及基礎語法
下一篇:今天遇到個問題。。。。
