实现了一个带有旋转动画的文字效果,包括容器、背景、文字和文字边框的样式,以及背景的动画效果。
Code
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>流光卡片</title>
<link rel="stylesheet" href="./53-流光卡片.css">
</head>
<body>
<div class="box">
<span></span>
<h2>01</h2>
</div>
</body>
</html>
CSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #0c1022;
}
.box {
position: relative;
width: 300px;
height: 400px;
background: rgba(0, 0, 0, .75);
border-radius: 20px;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
.box::after {
content: "";
position: absolute;
width: 500px;
height: 500px;
background-image: conic-gradient(transparent, transparent, transparent, #de44d4);
animation: animate 4s linear infinite;
animation-delay: -2s;
}
.box::before {
content: "";
position: absolute;
width: 500px;
height: 500px;
background-image: conic-gradient(transparent, transparent, transparent, #00ccff);
animation: animate 4s linear infinite;
}
@keyframes animate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.box span {
position: absolute;
inset: 5px;
border-radius: 16px;
background: #0c1022;
z-index: 1;
}
.box h2 {
position: relative;
z-index: 2;
color: #fff;
font-size: 10em;
}
实现思路拆分
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
设置所有元素的外边距和内边距为0,并使用border-box盒模型。
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #0c1022;
}
设置页面的样式,采用flex布局,水平和垂直居中,最小高度为100vh,背景颜色为深蓝色。
.box {
position: relative;
width: 300px;
height: 400px;
background: rgba(0, 0, 0, .75);
border-radius: 20px;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
设置容器的样式,包括定位、宽度、高度、背景颜色、圆角、采用flex布局、水平和垂直居中、溢出隐藏。
.box::after {
content: "";
position: absolute;
width: 500px;
height: 500px;
background-image: conic-gradient(transparent, transparent, transparent, #de44d4);
animation: animate 4s linear infinite;
animation-delay: -2s;
}
.box::before {
content: "";
position: absolute;
width: 500px;
height: 500px;
background-image: conic-gradient(transparent, transparent, transparent, #00ccff);
animation: animate 4s linear infinite;
}
设置容器的背景样式,包括定位、宽度、高度、背景渐变、动画效果和动画延迟。
@keyframes animate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
定义背景动画的关键帧,使背景颜色在4秒内旋转360度。
.box span {
position: absolute;
inset: 5px;
border-radius: 16px;
background: #0c1022;
z-index: 1;
}
.box h2 {
position: relative;
z-index: 2;
color: #fff;
font-size: 10em;
}
设置文字和文字边框的样式,包括定位、内边距、圆角、背景颜色和层级。
THE END
匿名
2025-10-22
盖楼盖楼!
匿名
2025-08-11
沙发沙发
匿名
2025-08-10
https://at.oiik.cn/bing.html
匿名
2025-02-21
实用,我在开发https://minmail.app/时候使用到了
王飞翔
2024-12-30
亲爱的朋友:您好!中国疫情持续蔓延,很多人症状非常严重持久不愈,医院人满为患,各年龄段随地倒猝死的现象暴增,多省感染手足口、甲流、乙流、支原体、合胞及腺病毒的儿童不断攀升,目前各种天灾人祸,天气异象频发。古今中外的很多预言都说了这几年人类有大灾难,如刘伯温在预言中说 “贫者一万留一千,富者一万留二三”,“贫富若不回心转,看看死期到眼前”, 预言中也告诉世人如何逃离劫难的方法,真心希望您能躲过末劫中的劫难,有个美好的未来,请您务必打开下方网址认真了解,内有躲避瘟疫保平安的方法。网址1:https://github.com/1992513/www/blob/master/README.md?abhgc#1 网址2:bitly.net/55bbbb 网址3:https://d3ankibxiji86m.cloudfront.net/30gj 如打不开请多换几个浏览器试
匿名
2024-12-12
Backdata 搜索引擎网址提交入口:https://backdata.net/submit-site.html