魔法边框
coderljw 2024-10-13 小于 1 分钟
<main>
<section></section>
</main>
1
2
3
2
3
main {
height: 400px;
display: grid;
place-items: center;
background: #000;
}
section {
width: 50%;
height: 50%;
border: 10px solid;
border-image: linear-gradient(45deg, gold, deeppink) 1;
clip-path: inset(0 round 10px);
animation: hue-rotate 3s infinite linear;
filter: hue-rotate(360deg);
}
@keyframes hue-rotate {
0% {
filter: hue-rotate(0deg);
}
100% {
filter: hue-rotate(360deg);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<main>
<section></section>
</main>
1
2
3
2
3
main {
height: 400px;
display: grid;
place-items: center;
background: #000;
}
section {
position: relative;
z-index: 0;
width: 50%;
height: 50%;
border-radius: 10px;
overflow: hidden;
background: rgba(168, 239, 255, 0.1);
}
section::before {
content: ' ';
position: absolute;
z-index: -2;
left: -50%;
top: -50%;
width: 200%;
height: 200%;
background: conic-gradient(
transparent,
rgba(168, 239, 255, 1),
transparent 30%
);
animation: rotate 3s linear infinite;
}
section::after {
content: ' ';
position: absolute;
z-index: -1;
left: 6px;
top: 6px;
width: calc(100% - 12px);
height: calc(100% - 12px);
background: #000;
border-radius: 5px;
}
@keyframes rotate {
100% {
transform: rotate(1turn);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50