上效果先:

先言:
這是在網上看到的效果,覺得挺有趣,所以我也弄了一個然后寫篇文章記錄,
實作:
1.定義html標簽:
<h1>
<span>北</span>
<span>極</span>
<span>光</span>
<span>之</span>
<span>夜</span>
</h1>
2.文字的基本樣式,大小顏色等:
h1{
font-family: 'fangsong';
font-size: 6em;
color: rgba(19, 18, 18, 0.8);
}
span{
display: table-cell;
animation: san 1.5s linear infinite;
}
display: table-cell;此元素會作為一個表格單元格顯示(類似 和 )
3.文字發亮的效果,就閃一下然后就又會(5%-95%的時候)變暗:
@keyframes san{
0%{
color: rgb(255, 255, 255);
text-shadow: 0 0 5px rgb(1, 210, 247),
0 0 15px rgb(1, 210, 247),
0 0 25px rgb(1, 210, 247),
0 0 50px rgb(1, 210, 247),
0 0 80px rgb(1, 210, 247),
0 0 120px rgb(1, 210, 247),
0 0 160px rgb(1, 210, 247),
0 0 200px rgb(1, 210, 247);
}
5%,95%{
color: rgba(19, 18, 18, 0.8);
text-shadow: none;
}
100%{
color: rgb(255, 255, 255);
text-shadow: 0 0 5px rgb(1, 210, 247),
0 0 15px rgb(1, 210, 247),
0 0 25px rgb(1, 210, 247),
0 0 50px rgb(1, 210, 247),
0 0 80px rgb(1, 210, 247),
0 0 120px rgb(1, 210, 247),
0 0 160px rgb(1, 210, 247),
0 0 200px rgb(1, 210, 247);
}
}
text-shadow:是給它加陰影,寫了很多行是為了陰影更亮;
4.制造時間差,讓不同的時間不同的文字亮;
h1 span:nth-child(1){
animation-delay:0s;
}
h1 span:nth-child(2){
animation-delay:0.3s;
}
h1 span:nth-child(3){
animation-delay:0.6s;
}
h1 span:nth-child(4){
animation-delay:0.9s;
}
h1 span:nth-child(5){
animation-delay:1.2s;
}
animation-delay 等待多少秒,然后才開始影片;
完整代碼:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
body{
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-color: rgb(0, 0, 0);
}
h1{
font-family: 'fangsong';
font-size: 6em;
color: rgba(19, 18, 18, 0.8);
}
span{
display: table-cell;
animation: san 1.5s linear infinite;
}
h1 span:nth-child(1){
animation-delay:0s;
}
h1 span:nth-child(2){
animation-delay:0.3s;
}
h1 span:nth-child(3){
animation-delay:0.6s;
}
h1 span:nth-child(4){
animation-delay:0.9s;
}
h1 span:nth-child(5){
animation-delay:1.2s;
}
@keyframes san{
0%{
color: rgb(255, 255, 255);
text-shadow: 0 0 5px rgb(1, 210, 247),
0 0 15px rgb(1, 210, 247),
0 0 25px rgb(1, 210, 247),
0 0 50px rgb(1, 210, 247),
0 0 80px rgb(1, 210, 247),
0 0 120px rgb(1, 210, 247),
0 0 160px rgb(1, 210, 247),
0 0 200px rgb(1, 210, 247);
}
5%,95%{
color: rgba(19, 18, 18, 0.8);
text-shadow: none;
}
100%{
color: rgb(255, 255, 255);
text-shadow: 0 0 5px rgb(1, 210, 247),
0 0 15px rgb(1, 210, 247),
0 0 25px rgb(1, 210, 247),
0 0 50px rgb(1, 210, 247),
0 0 80px rgb(1, 210, 247),
0 0 120px rgb(1, 210, 247),
0 0 160px rgb(1, 210, 247),
0 0 200px rgb(1, 210, 247);
}
}
</style>
</head>
<body>
<h1>
<span>北</span>
<span>極</span>
<span>光</span>
<span>之</span>
<span>夜</span>
</h1>
</body>
</html>
總結:
每天都對自己說:
生活不止眼前的茍且
還有詩和遠方的田野
你赤手空拳來到人世間
為找到那片海不顧一切~

轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/241859.html
標籤:其他
上一篇:2020/12/27-每日三題第3彈:你對瀏覽器內核了解多少呢,標簽語意化又是什么東東呢???
下一篇:一個好看的input輸入影片
