让我们先来看看实现的效果
html代码
<!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>第二十二天</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="box">
<div class="content">
<h1>d1as3das</h1>
<p> d456as4d56as4d65as
dasd4as56d465as
das456d4sa654d65a</p>
</div>
</div>
</body>
</html>
css代码
@import url('https://fonts.googleapis.com/css?family=Poppins:100,200,300,400,500,600,700,800,900');
body{
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #060c21;
font-family: 'Poppins',sans-serif;
}
.box{
position: relative;
width: 300px;
height: 400px;
display: flex;
justify-content: center;
align-items: center;
background: #060c21 ;
animation: animate 4s linear infinite;
}
.box:before{
content: '';
position: absolute;
top: -2px;
left: -2px;
right: -2px;
bottom: -2px;
background: #fff;
z-index: -1;
}
.box:before{
content: '';
position: absolute;
top: -2px;
left: -2px;
right: -2px;
bottom: -2px;
background: #fff;
z-index: -2;
filter:blur(40px)
}
.box:before,.box:after{
background: linear-gradient(235deg,#89ff00,#060c21,#00bcd4);
}
.content{
padding: 20px;
box-sizing: border-box;
color: #fff;
}
@keyframes animate {
100% {
filter: hue-rotate(360deg);
}
}
设计思路与今日份知识总结
设计思路
1.before,after造一个比原先扩大2px的box
2.用z-index来控制中间的部分被覆盖,所以就出现了我们的边框
3.linear-gradient()函数做出渐变色,就会变成下面的效果
4.用动画和hue-rotate(360deg)函数完成边框的色旋旋转就导致了最终的结果!
知识总结
标签 | 作用 |
---|---|
@import url() | @import只能加载css |
min-height | 属性设置元素的最小高度 |
z-index | z-index 属性设置元素的堆叠顺序。拥有更高堆叠顺序的元素总是会处于堆叠顺序较低的元素的前面。 |
hue-rotate | hue-rotate()函数是一个内置函数,用于对图像应用滤镜以设置图像的色调旋转。 |
box-sizing | box-sizing 属性允许您以特定的方式定义匹配某个区域的特定元素。 |
linear-gradient | 用于创建一个表示两种或多种颜色线性渐变的图片 |