三色边框旋转加载特效 html+css

效果:

在这里插入图片描述

实现:

1. 定义标签,.box是底层盒子,.circle里的3个span元素就是效果图里的3条颜色边框。h5就是文字。:

 <div class="box">
           <div class="circle">
             <span></span>
             <span></span>
             <span></span>
           </div>
        <h5>NIGHT.</h5>
    </div>

2. 给.box与.ciecle基本样式,采用定位:

 .box{
    
    
            width: 150px;
            height: 150px;
            position: relative;
        }
   .circle{
    
    
            width: 100%;
            height: 100%;
            position: absolute;
        }

3. 设置3条颜色边框基本样式,绝对定位:

 .circle span{
    
    
            display: inline-block;
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;

        }

display: inline-block;转为行内块元素。

4.设置第一条:

 .circle span:nth-child(1){
    
    
            border-radius: 50%;
            border-top: 15px rgb(243, 6, 6) solid;
            filter: drop-shadow(0 0 15px rgb(255, 0, 0));
            
        }

原理:当设置角弧度为50%的时候再设置只有一条边的边框,边框就会呈现出月牙的形状。我这设置上边框。
filter: drop-shadow 设置阴影,为什么不用box-shadow,因为box-shadow是在整个元素背后呈现出一个矩形阴影,而drop-shadow却能呈现出符合当前图形形状的阴影,而这只需要呈现出月牙形状边框的阴影。

5. 同理设置第二条:

.circle span:nth-child(2){
    
    
            border-radius: 50%;
            border-top: 15px rgb(0, 110, 255) solid;
            transform: rotateZ(120deg);
            filter: drop-shadow(0 0 15px  rgb(0, 132, 255));
          
        }

transform: rotateZ(120deg); 让它旋转120度。

6.第三条:

  .circle span:nth-child(3){
    
    
            border-radius: 50%;
            border-top: 15px rgb(0, 255, 42) solid;
            transform: rotateZ(240deg);
            filter: drop-shadow(0 0 15px  rgb(30, 255, 0));
        }

transform: rotateZ(240deg); 旋转240度。

7.给 .circle 设置动画,让其旋转:

 .circle{
    
    
            width: 100%;
            height: 100%;
            position: absolute;
            animation: turn 3s linear infinite;
        }
        @keyframes turn{
    
    
            100%{
    
    
                transform: rotateZ(360deg);
            }
        }

animation: turn 3s linear infinite; 动画。
transform: rotateZ(360deg); 转360度。

8. 设置字体样式和动画:

.box h5{
    
    
        font-family: 'MedievalSharp', cursive;
           position: absolute;
           top: 0;
           left: 0;
           width: 100%;
           height: 100%;
           line-height: 150px;
           text-align: center;
           font-size: 23px;
           color: rgb(4, 174, 253);
           letter-spacing: 1.5px;
           
           animation: bian 12s linear infinite;
           text-shadow: 0 0 10px rgb(4, 174, 253),
                          0 0 50px rgb(4, 174, 253);
       }
       @keyframes bian{
    
    
 
           50%{
    
    
            text-shadow: 0 0 10px rgb(4, 174, 253);
               filter: hue-rotate(360deg);
           }
       }

font-family: ‘MedievalSharp’, cursive; 字体样式 可以去这个网址获取

letter-spacing: 1.5px; 字体间距;

text-shadow: 0 0 10px rgb(4, 174, 253),
0 0 50px rgb(4, 174, 253); 阴影,两行能让阴影更亮,叠加效果。

filter: hue-rotate(360deg); 色相旋转,放动画里这样就可以让字体颜色一直变换。

完整代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="https://fonts.font.im/css?family=MedievalSharp" rel="stylesheet">
    <style>
        *{
     
     
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body{
     
     
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: #000000;
        }
        .box{
     
     
            width: 150px;
            height: 150px;
            position: relative;
        }
        .circle{
     
     
            width: 100%;
            height: 100%;
            position: absolute;
            animation: turn 3s linear infinite;
        }
        @keyframes turn{
     
     
            100%{
     
     
                transform: rotateZ(360deg);
            }
        }
        .circle span{
     
     
            display: inline-block;
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;

        }
     
        .circle span:nth-child(1){
     
     
            border-radius: 50%;
            border-top: 15px rgb(243, 6, 6) solid;
            filter: drop-shadow(0 0 15px rgb(255, 0, 0));
            
        }
        .circle span:nth-child(2){
     
     
            border-radius: 50%;
            border-top: 15px rgb(0, 110, 255) solid;
            transform: rotateZ(120deg);
            filter: drop-shadow(0 0 15px  rgb(0, 132, 255));
          
        }
        .circle span:nth-child(3){
     
     
            border-radius: 50%;
            border-top: 15px rgb(0, 255, 42) solid;
            transform: rotateZ(240deg);
            filter: drop-shadow(0 0 15px  rgb(30, 255, 0));
        }
       .box h5{
     
     
        font-family: 'MedievalSharp', cursive;
           position: absolute;
           top: 0;
           left: 0;
           width: 100%;
           height: 100%;
           line-height: 150px;
           text-align: center;
           font-size: 23px;
           color: rgb(4, 174, 253);
           letter-spacing: 1.5px;
           
           animation: bian 12s linear infinite;
           text-shadow: 0 0 10px rgb(4, 174, 253),
                          0 0 50px rgb(4, 174, 253);
       }
       @keyframes bian{
     
     
 
           50%{
     
     
            text-shadow: 0 0 10px rgb(4, 174, 253);
               filter: hue-rotate(360deg);
           }
       }
    </style>
</head>
<body>
    <div class="box">
           <div class="circle">
        <span></span>
        <span></span>
        <span></span>
           </div>
        <h5>NIGHT.</h5>
    </div>
</body>
</html>

总结:

其它文章~:
气泡浮动背景特效 html+css
简约时钟特效 html+css+js
赛博朋克风格按钮 html+css
响应式卡片悬停效果 html+css
水波加载动画 html+css
导航栏滚动渐变效果 html+css+js
书本翻页 html+css
3D立体相册 html+css
炫彩流光按钮 html+css
记一些css属性总结(一)
Sass总结笔记
…等等

牛年快乐,一切顺利~

猜你喜欢

转载自blog.csdn.net/luo1831251387/article/details/113775071