<!DOCTYPE html>
<html lang="en">
<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>
html,body{
height: 100%;
--borderWidth:3px;
}
body{
display: flex;
justify-content: center;
align-items: center;
height: 100%;
background-color: black;
}
.content{
width: 300px;
height: 200px;
display: flex;
justify-content: center;
align-items: center;
background-color: black;
color: #fff;
font-size: 2rem;
}
.gradient{
position: relative;
}
.gradient::before{
content: "";
position: absolute;
width: calc(300px + var(--borderWidth) * 2);
height: calc(200px + var(--borderWidth) * 2);
/* background-color: pink; */
background: linear-gradient(60deg,red,yellow,green,orange,blue);
border-radius: calc(2 * var(--borderWidth));
background-size: 300% 300%;
animation: aniamted 3s infinite;
z-index: -1;
}
@keyframes aniamted{
0%{
background-position: 0% 50%;
}
50%{
background-position: 100% 50%;
}
100%{
background-position: 0% 50%;
}
}
</style>
</head>
<body>
<div class="content gradient">
helloWorld
</div>
</body>
</html>
跟着网络来自学,#学习笔记#前端第三天:[html+css小项目]炫彩边框
于 2023-03-09 21:38:44 首次发布