5分鐘教你學會超簡單的html+css魔幻霓虹燈文字特效
話不多,先看效果:

今天繼續(xù)分享簡單但有趣的CSS創(chuàng)意特效~
這個效果很簡單看一分鐘就明白了~
初學前端的小伙伴們拿來練手是很不錯的~
實現(xiàn)過程(完整源碼在最后):
1. 定義h3標簽:
<h3>Aurora Borealis night</h3>
2. 給個body背景色:
body{
background-color: rgb(4, 15, 36);
}
3. 設(shè)置h3基本樣式:
h3{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 100%;
text-align: center;
font-size: 3em;
text-transform: uppercase;
letter-spacing: 10px;
color: rgb(4, 15, 36);
-webkit-box-reflect: below 1px linear-gradient(transparent ,rgb(218, 218, 218));
animation: san 6s linear infinite;
}
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%); 居中對齊。先left與top 50%,再偏移自身長度與寬度50%達到居中。
text-align: center; 文字居中。
text-transform: uppercase; 字母變?yōu)榇髮憽?br />letter-spacing: 10px; 每個字符間距離。
-webkit-box-reflect: 倒影效果。
animation: san 6s linear infinite; 定義動畫。
4.定義動畫,就是設(shè)置不同時間段顯示不同顏色等實現(xiàn)閃爍霓虹燈效果~時間可以自己調(diào)自己要的效果:
@keyframes san{
0%,15%,50%,52%,70%,90%,99.1%{
color: rgb(4, 15, 36);
filter: blur(2px);
}
12%,15.1%,60%,70.1%,90.5%,100%{
color: rgb(255, 255, 255);
text-shadow: 0 0 5px rgb(22, 138, 216),
0 0 25px rgb(22, 138, 216),
0 0 35px rgb(22, 138, 216),
0 0 105px rgb(22, 138, 216),
0 0 155px rgb(22, 138, 216);
filter: blur(0px);
}
}
filter: blur(2px); 模糊
text-shadow: 0 0 5px rgb(22, 138, 216),
0 0 25px rgb(22, 138, 216),
0 0 35px rgb(22, 138, 216),
0 0 105px rgb(22, 138, 216),
0 0 155px rgb(22, 138, 216);
文字陰影。寫多行是為了陰影疊加,效果更亮。
完整源碼:
<!DOCTYPE html>
<html lang="zh-CN">
<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>Document</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
background-color: rgb(4, 15, 36);
}
h3{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 100%;
text-align: center;
font-size: 3em;
text-transform: uppercase;
letter-spacing: 10px;
color: rgb(4, 15, 36);
-webkit-box-reflect: below 1px linear-gradient(transparent ,rgb(218, 218, 218));
animation: san 6s linear infinite;
}
@keyframes san{
0%,15%,50%,52%,70%,90%,99.1%{
color: rgb(4, 15, 36);
filter: blur(2px);
}
12%,15.1%,60%,70.1%,90.5%,100%{
color: rgb(255, 255, 255);
text-shadow: 0 0 5px rgb(22, 138, 216),
0 0 25px rgb(22, 138, 216),
0 0 35px rgb(22, 138, 216),
0 0 105px rgb(22, 138, 216),
0 0 155px rgb(22, 138, 216);
filter: blur(0px);
}
}
</style>
</head>
<body>
<h3>Aurora Borealis night</h3>
</body>
</html>
到此這篇關(guān)于5分鐘教你學會超簡單的html+css魔幻霓虹燈文字特效的文章就介紹到這了,更多相關(guān)html+css霓虹燈文字特效內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

