纯CSS如何实现血轮眼+轮回眼特效(代码详解)

本篇文章给大家介绍一下使用纯css实现血轮眼+轮回眼特效的方法。有一定的参考价值,有需要的朋友可以参考一下,希望对你们有所助。

血轮眼

效果(完整代码在底部)

其实实现并不难,都是重复的代码比较多。

实现(可跟着一步一步写):

1. 先定义基本标签:

    
                
                        
                                                                            
        
    
        
                
                         
                                                                                    
           

登录后复制

2. 定义左右眼的基本css样式:

立即学习“前端免费学习笔记(深入)”;

.zuo , .you{             width: 250px;            height: 120px;            background-color: rgb(255, 255, 255);            border-bottom: 5px solid rgb(70, 70, 70);            overflow: hidden;            position: relative;        }

登录后复制

border-bottom: 5px solid rgb(70, 70, 70); 给个灰色的眼底。

overflow:溢出隐藏。

position: relative; 相对定位。

3. 开始先定义血轮眼的基本样式:

.zuo{            transform: translateX(-135px);            border-radius: 0 120px 0 120px;            box-shadow: inset 3px 2px 3px  rgba(17, 17, 17, 0.8);        }

登录后复制

transform: translateX(-135px); 向左偏移,让两眼分开。border-radius:给两个角设置弧度,形成眼睛形状。bos-shadowL给眼角一点阴影。

4. 设置眼球宽高等:

.zuo::after{            content: '';            position: absolute;            top: 50%;            left: 50%;            transform: translate(-50%,-50%);            width: 95px;            height: 95px;            border-radius: 50%;            border: 2px solid #000;            animation: colour 2s linear forwards;        }        @keyframes colour{            0%,30%{                background-color: rgb(0, 0, 0);            }            100%{                 background-color: rgb(255, 4, 4);             }         }

登录后复制

5. 设置眼球正中间的黑点,都是些定位大小啥的,然后设置动画然它慢慢变大:

 .zuoZong{            position: absolute;            top: 50%;            left: 50%;            transform: translate(-50%,-50%);            width: 0px;            height: 0px;            border-radius: 50%;            background-color: rgb(0, 0, 0);            z-index: 1;            animation: da 3s linear forwards;        }        @keyframes da{            100%{                width: 15px;            height: 15px;            }        }

登录后复制

6. 设置三勾玉所在的圈,设置动画让其显示与旋转:

.zuoYu{            position: absolute;            top: -25px;            left: -25px;            bottom: -25px;            right: -25px;            border-radius: 50%;            border: 2px solid rgb(0, 0, 0);            animation: zhuan 2s linear 2s forwards;            opacity: 0;        }        @keyframes zhuan{                       100%{                opacity: 1;                transform: rotate(720deg);            }        }

登录后复制

7. 制作三勾玉,先做一个圆,再用双伪类制作一个圆弧,两者结合就是勾玉了:

.zuoYu .yu{             position: absolute;             width: 15px;             height: 15px;             border-radius: 50%;             background-color: rgb(0, 0, 0);        }        .zuoYu .yu::after{            content: '';            position: absolute;            top: -6px;            left: -1px;            width: 6px;            height: 20px;            border-radius: 50%;            border-left: 6px solid rgb(0, 0, 0);        }

登录后复制

border-radius: 50%;

border-left: 6px solid rgb(0, 0, 0);

先让伪类为圆,再只设置一条边框,圆弧形成,再定位在父元素上,形成勾玉。

8. 给勾玉设置动画,让其从最中间变大旋转到勾玉所在的圈:

  .zuoYu .yu:nth-child(1){            animation: yu1 2s ease-in 2s  forwards;        }        @keyframes yu1{            0%{                opacity: 0;                left: 50%;                top: 50%;                                transform:translate(-50%,-50%)  scale(0.1) ;            }            100%{                left: 50%;                top: -9%;                transform: scale(1) rotate(80deg);              }        }

登录后复制

left: 50%;
top: 50%; 在最中间。
opacity:透明。
scale(0.1);缩小。
100%{…}到对应位置,同时变不透明和放大成正常大小。

9. 一样的,给其它两个勾玉动画:

.zuoYu .yu:nth-child(2){            animation: yu2 2s ease-in 2s forwards;         }        @keyframes yu2{            0%{                opacity: 0;                left: 50%;                top: 50%;                                transform: translate(-50%,-50%) scale(0.1) ;            }            100%{                top: 60%;                left: -9%;                transform: scale(1) rotate(-60deg);              }        }        .zuoYu .yu:nth-child(3){                      animation: yu3 2s ease-in 2s forwards;        }        @keyframes yu3{            0%{                opacity: 0;                right: 50%;                top: 50%;                                transform: translate(-50%,-50%) scale(0.1);            }            100%{                top: 60%;                right: -9%;                transform: scale(1) rotate(180deg);              }        }

登录后复制

10.给两个眼睛都设置一个白点,相当于反光效果吧,至此血轮眼做完了:

.zuo::before,.you::before{            content: '';            position: absolute;            left: 38%;            top: 30%;            width: 12px;            height: 12px;            border-radius: 50%;            background-color: rgb(255, 255, 255);            z-index: 10;        }

登录后复制

position: absolute;
left: 38%;
top: 30%; 定位相应的位置。
background-color: rgb(255, 255, 255); 白色。
z-index: 10; 设置为10,显示在最上层。

11.设置轮回眼基本css样式,跟血轮眼一样:

 .you{            transform: translateX(135px);            border-radius:  120px 0 120px 0;            box-shadow: inset -3px 2px 3px  rgba(17, 17, 17, 0.8);        }

登录后复制

12.设置眼球宽高等:

.you::after{            content: '';            position: absolute;            top: 50%;            left: 50%;            transform: translate(-50%,-50%);            width: 95px;            height: 95px;            border-radius: 50%;            border: 2px solid #000;            animation: youcolor 2s linear forwards;         }         @keyframes youcolor{            0%,30%{                background-color: rgb(0, 0, 0);            }            100%{                 background-color: rgb(144, 130, 183);                          }         }

登录后复制

position: absolute; 绝对定位
top: 50%;
left: 50%;
transform: translate(-50%,-50%); 居中对齐。
animation:设置动画,让其变紫色。forward:继承最后一帧的属性。
background-color: rgb(0, 0, 0); 黑色
background-color: rgb(144, 130, 183); 紫色。

13. 设置眼球最中间的黑点,跟血轮眼也差不多:

.dian{                    position: absolute;            top: 50%;            left: 50%;                          background-color: #000;            transform: translate(-50%,-50%);            border-radius: 50%;            z-index: 10;            animation: youda 3s linear forwards;         }         @keyframes youda{             0%{                height: 0px;            width: 0px;             }             100%{                height: 15px;            width: 15px;             }         }

登录后复制

14. 设置轮回眼每个圈,同时设置动画让其变大:

 .youYu{            position: absolute;          top: 50%;          left: 50%;          transform: translate(-50%,-50%);       }       .quan{           position: absolute;           border-radius: 50%;           border: 2px solid #000;           z-index: calc(1 - var(--r));           animation: zhi 2s ease-out 2s forwards;       }       @keyframes zhi{           0%{            top: calc(var(--r) * 1px);           left: calc(var(--r) * 1px);           right: calc(var(--r) * 1px);           bottom: calc(var(--r) * 1px);           }           100%{            top: calc(var(--r) * -35px);           left: calc(var(--r) * -35px);           right: calc(var(--r) * -35px);           bottom: calc(var(--r) * -35px);               background-color: rgb(187, 177, 214);           }       }

登录后复制

z-index: calc(1 – var(–r)); 计算,让最开始的圈显示在最上层。
animation:设置动画,让轮回圈慢慢变大,同时变成紫色。

完整代码:

nbsp;html>                Document            *{            margin: 0;            padding: 0;            box-sizing: border-box;        }        body{            height: 100vh;            display: flex;            justify-content: center;            align-items: center;            background-color: #000;        }        .zuo , .you{             width: 250px;            height: 120px;            background-color: rgb(255, 255, 255);            border-bottom: 5px solid rgb(70, 70, 70);            overflow: hidden;            position: relative;        }                 .zuo{            transform: translateX(-135px);            border-radius: 0 120px 0 120px;            box-shadow: inset 3px 2px 3px  rgba(17, 17, 17, 0.8);        }        .zuo::after{            content: '';            position: absolute;            top: 50%;            left: 50%;            transform: translate(-50%,-50%);            width: 95px;            height: 95px;            border-radius: 50%;            border: 2px solid #000;            animation: colour 2s linear forwards;        }        @keyframes colour{            0%,30%{                background-color: rgb(0, 0, 0);            }            100%{                 background-color: rgb(255, 4, 4);             }         }        .zuoZong{            position: absolute;            top: 50%;            left: 50%;            transform: translate(-50%,-50%);            width: 0px;            height: 0px;            border-radius: 50%;            background-color: rgb(0, 0, 0);            z-index: 1;            animation: da 3s linear forwards;        }        @keyframes da{            100%{                width: 15px;            height: 15px;            }        }        .zuoYu{            position: absolute;            top: -25px;            left: -25px;            bottom: -25px;            right: -25px;            border-radius: 50%;            border: 2px solid rgb(0, 0, 0);            animation: zhuan 2s linear 2s forwards;            opacity: 0;        }        @keyframes zhuan{                       100%{                opacity: 1;                transform: rotate(720deg);            }        }        .zuoYu .yu{             position: absolute;             width: 15px;             height: 15px;             border-radius: 50%;             background-color: rgb(0, 0, 0);        }        .zuoYu .yu::after{            content: '';            position: absolute;            top: -6px;            left: -1px;            width: 6px;            height: 20px;            border-radius: 50%;            border-left: 6px solid rgb(0, 0, 0);        }        .zuoYu .yu:nth-child(1){            animation: yu1 2s ease-in 2s  forwards;        }        @keyframes yu1{            0%{                opacity: 0;                left: 50%;                top: 50%;                                transform:translate(-50%,-50%)  scale(0.1) ;            }            100%{                left: 50%;                top: -9%;                transform: scale(1) rotate(80deg);              }        }               .zuoYu .yu:nth-child(2){            animation: yu2 2s ease-in 2s forwards;         }        @keyframes yu2{            0%{                opacity: 0;                left: 50%;                top: 50%;                                transform: translate(-50%,-50%) scale(0.1) ;            }            100%{                top: 60%;                left: -9%;                transform: scale(1) rotate(-60deg);              }        }        .zuoYu .yu:nth-child(3){                      animation: yu3 2s ease-in 2s forwards;        }        @keyframes yu3{            0%{                opacity: 0;                right: 50%;                top: 50%;                                transform: translate(-50%,-50%) scale(0.1);            }            100%{                top: 60%;                right: -9%;                transform: scale(1) rotate(180deg);              }        }        .zuo::before,.you::before{            content: '';            position: absolute;            left: 38%;            top: 30%;            width: 12px;            height: 12px;            border-radius: 50%;            background-color: rgb(255, 255, 255);            z-index: 10;        }        .you{            transform: translateX(135px);            border-radius:  120px 0 120px 0;            box-shadow: inset -3px 2px 3px  rgba(17, 17, 17, 0.8);/*             filter: drop-shadow( 8px -5px 3px  rgb(216, 59, 59)); */        }         .you::after{            content: '';            position: absolute;            top: 50%;            left: 50%;            transform: translate(-50%,-50%);            width: 95px;            height: 95px;            border-radius: 50%;            border: 2px solid #000;            animation: youcolor 2s linear forwards;         }         @keyframes youcolor{            0%,30%{                background-color: rgb(0, 0, 0);            }            100%{                 background-color: rgb(144, 130, 183);                          }         }                  .dian{                    position: absolute;            top: 50%;            left: 50%;                          background-color: #000;            transform: translate(-50%,-50%);            border-radius: 50%;            z-index: 10;            animation: youda 3s linear forwards;         }         @keyframes youda{             0%{                height: 0px;            width: 0px;             }             100%{                height: 15px;            width: 15px;             }         }         .youYu{            position: absolute;          top: 50%;          left: 50%;          transform: translate(-50%,-50%);       }       .quan{           position: absolute;           border-radius: 50%;           border: 2px solid #000;           z-index: calc(1 - var(--r));           animation: zhi 2s ease-out 2s forwards;       }       @keyframes zhi{           0%{            top: calc(var(--r) * 1px);           left: calc(var(--r) * 1px);           right: calc(var(--r) * 1px);           bottom: calc(var(--r) * 1px);           }           100%{            top: calc(var(--r) * -35px);           left: calc(var(--r) * -35px);           right: calc(var(--r) * -35px);           bottom: calc(var(--r) * -35px);               background-color: rgb(187, 177, 214);           }       }            
                
                        
                                                                            
        
    
        
                
                         
                                                                                    
           

登录后复制

(学习视频分享:css视频教程)

以上就是纯CSS如何实现血轮眼+轮回眼特效(代码详解)的详细内容,更多请关注【创想鸟】其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2873152.html

(0)
上一篇 2025年3月10日 18:50:18
下一篇 2025年3月10日 18:50:34

AD推荐 黄金广告位招租... 更多推荐

相关推荐

  • css怎么设置文本框宽度

    在css中,可以使用width属性来设置文本框宽度,只需要给文本框元素textarea添加“width:宽度值;”样式即可。width属性可以设置元素的宽度,它定义了元素内容区的宽度,在内容区外面可以增加内边距、边框和外边距。 本教程操作环…

    2025年3月10日
    000
  • css样式冲突怎么办

    解决方法:1、细化选择符,将选择器的描述写得更加精确;2、再写一次选择器名;3、改变CSS样式表中的顺序;4、主动提升优先级,在需要使用的样式后加上关键字“!important”。 本教程操作环境:windows7系统、CSS3&&…

    2025年3月10日
    200
  • css如何设置所有标签

    设置方法:1、将所有标签都列出来,语法“body,ol,ul,h1,h2,h3,h4,h5,h6,p,th…{属性:属性值;}”;2、使用*进行设置,语法格式为“*{属性:属性值;}”。 本教程操作环境:windows7系统、C…

    2025年3月10日
    200
  • css结构化伪类选择器有哪些

    选择器有::root、:not、:only-child、:first-child、:last-child、:empty:target、:nth-child(n)、nth-last-child(n)、:nth-of-type(n)等。 本教程…

    2025年3月10日 编程技术
    200
  • css中绝对定位什么意思

    绝对定位意思是将被赋予此定位方法的对象从文档流中拖出,使用left,right,top, bottom等属性相对于其最接近的一个最有定位设置的父级对象进行绝对定位,如果对象的父级没有设置定位属性,即还是遵循HTML定位规则的。 本教程操作环…

    2025年3月10日
    200
  • css的属性有哪些

    css属性有:1、字体属性,font;2、背景属性,background;3、区块属性,block;4、方框属性,box;5、边框属性,border;6、列表属性,list-style;8、定位属性,position等。 本教程操作环境:w…

    2025年3月10日
    200
  • 为什么css不起作用

    css不起作用的原因是:1、html标签没写完整,漏了“”或者“/”等;2、样式表保存的编码错误;3、样式被层叠;4、CSS语法错误;5、选择器写错。 本教程操作环境:windows7系统、CSS3&&HTML5版、Dell…

    2025年3月10日
    200
  • css样式由什么组成

    CSS样式由选择器、属性和值三部分构成。选择器通常是你希望定义的HTML元素或标签,属性是你希望改变的属性,并且每个属性都有一个值。属性和值被冒号分开,并由花括号包围,这样就组成了一个完整的样式声明。 本教程操作环境:windows7系统、…

    2025年3月10日
    200
  • css上边距怎么设置

    css设置上边距的方法:1、使用margin-top属性设置元素的上外边距;2、使用padding-top属性设置元素的上内边距。margin-top和padding-top属性接受任何长度单位,可以是像素、英寸、毫米或em。 本教程操作环…

    2025年3月10日
    200
  • css怎么设置元素透明度

    在css中,可以使用opacity属性来设置元素的透明度,只需要给元素添加“opacity:value;”样式即可;其中参数“value”指定元素的透明度,值的范围为“0.0~1.0”,“0.0”表示完全透明,“1.0”表示完全不透明。 本…

    2025年3月10日
    200

发表回复

登录后才能评论