经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » HTML/CSS » CSS » 查看文章
html+css实现血轮眼轮回眼特效代码_HTML/Xhtml
来源:jb51  时间:2021/4/6 9:27:56  对本文有异议

效果(完整代码在底部):

血轮眼

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

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

1. 先定义基本标签:

  1. <!-- 血轮眼 -->
  2. <div class="zuo">
  3. <!-- 眼睛最中间那个黑点 -->
  4. <div class="zuoZong">
  5. <!-- 三勾玉所在的圈 -->
  6. <div class="zuoYu">
  7. <!-- 三个勾玉 -->
  8. <span class="yu"></span>
  9. <span class="yu"></span>
  10. <span class="yu"></span>
  11. </div>
  12. </div>
  13. </div>
  14. <!-- 轮回眼 -->
  15. <div class="you">
  16. <!-- 眼睛最中间那个黑点 -->
  17. <div class="dian"></div>
  18. <!-- 3个轮回圈 -->
  19. <div class="youYu">
  20. <span class="quan" style="--r:2;"></span>
  21. <span class="quan" style="--r:3;"></span>
  22. <span class="quan" style="--r:4;"></span>
  23. </div>
  24. </div>

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

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

border-bottom: 5px solid rgb(70, 70, 70); 给个灰色的眼底。
overflow:溢出隐藏。
position: relative; 相对定位。

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

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

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

4. 设置眼球宽高等:

  1. .zuo::after{
  2. content: '';
  3. position: absolute;
  4. top: 50%;
  5. left: 50%;
  6. transform: translate(-50%,-50%);
  7. width: 95px;
  8. height: 95px;
  9. border-radius: 50%;
  10. border: 2px solid #000;
  11. animation: colour 2s linear forwards;
  12. }
  13. @keyframes colour{
  14. 0%,30%{
  15. background-color: rgb(0, 0, 0);
  16. }
  17. 100%{
  18. background-color: rgb(255, 4, 4);
  19. }
  20. }

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

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

  1. .zuoZong{
  2. position: absolute;
  3. top: 50%;
  4. left: 50%;
  5. transform: translate(-50%,-50%);
  6. width: 0px;
  7. height: 0px;
  8. border-radius: 50%;
  9. background-color: rgb(0, 0, 0);
  10. z-index: 1;
  11. animation: da 3s linear forwards;
  12. }
  13. @keyframes da{
  14. 100%{
  15. width: 15px;
  16. height: 15px;
  17. }
  18. }

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

  1. .zuoYu{
  2. position: absolute;
  3. top: -25px;
  4. left: -25px;
  5. bottom: -25px;
  6. right: -25px;
  7. border-radius: 50%;
  8. border: 2px solid rgb(0, 0, 0);
  9. animation: zhuan 2s linear 2s forwards;
  10. opacity: 0;
  11. }
  12. @keyframes zhuan{
  13. 100%{
  14. opacity: 1;
  15. transform: rotate(720deg);
  16. }
  17. }

position: absolute;
top: -25px;
left: -25px;
bottom: -25px;
right: -25px; 大小。
border-radius: 50%;圆形。
border: 2px solid rgb(0, 0, 0); 黑色边框。
opacity:0;透明度为0;
transform: rotate(720deg); 旋转720度。

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

  1. .zuoYu .yu{
  2. position: absolute;
  3. width: 15px;
  4. height: 15px;
  5. border-radius: 50%;
  6. background-color: rgb(0, 0, 0);
  7.  
  8. }
  9. .zuoYu .yu::after{
  10. content: '';
  11. position: absolute;
  12. top: -6px;
  13. left: -1px;
  14. width: 6px;
  15. height: 20px;
  16. border-radius: 50%;
  17. border-left: 6px solid rgb(0, 0, 0);
  18. }

border-radius: 50%;
border-left: 6px solid rgb(0, 0, 0);
先让伪类为圆,再只设置一条边框,圆弧形成,再定位在父元素上,形成勾玉。

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

  1. .zuoYu .yu:nth-child(1){
  2. animation: yu1 2s ease-in 2s forwards;
  3. }
  4. @keyframes yu1{
  5. 0%{
  6. opacity: 0;
  7. left: 50%;
  8. top: 50%;
  9. transform:translate(-50%,-50%) scale(0.1) ;
  10. }
  11. 100%{
  12. left: 50%;
  13. top: -9%;
  14. transform: scale(1) rotate(80deg);
  15. }
  16. }

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

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

  1. .zuoYu .yu:nth-child(2){
  2. animation: yu2 2s ease-in 2s forwards;
  3. }
  4. @keyframes yu2{
  5. 0%{
  6. opacity: 0;
  7. left: 50%;
  8. top: 50%;
  9. transform: translate(-50%,-50%) scale(0.1) ;
  10. }
  11. 100%{
  12. top: 60%;
  13. left: -9%;
  14. transform: scale(1) rotate(-60deg);
  15. }
  16. }
  17. .zuoYu .yu:nth-child(3){
  18. animation: yu3 2s ease-in 2s forwards;
  19. }
  20. @keyframes yu3{
  21. 0%{
  22. opacity: 0;
  23. right: 50%;
  24. top: 50%;
  25. transform: translate(-50%,-50%) scale(0.1);
  26. }
  27. 100%{
  28. top: 60%;
  29. right: -9%;
  30. transform: scale(1) rotate(180deg);
  31. }
  32. }

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

  1. .zuo::before,.you::before{
  2. content: '';
  3. position: absolute;
  4. left: 38%;
  5. top: 30%;
  6. width: 12px;
  7. height: 12px;
  8. border-radius: 50%;
  9. background-color: rgb(255, 255, 255);
  10. z-index: 10;
  11. }

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

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

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

12.设置眼球宽高等:

  1. .you::after{
  2. content: '';
  3. position: absolute;
  4. top: 50%;
  5. left: 50%;
  6. transform: translate(-50%,-50%);
  7. width: 95px;
  8. height: 95px;
  9. border-radius: 50%;
  10. border: 2px solid #000;
  11. animation: youcolor 2s linear forwards;
  12. }
  13. @keyframes youcolor{
  14. 0%,30%{
  15. background-color: rgb(0, 0, 0);
  16. }
  17. 100%{
  18. background-color: rgb(144, 130, 183);
  19. }
  20. }

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. 设置眼球最中间的黑点,跟血轮眼也差不多:

  1. .dian{
  2. position: absolute;
  3. top: 50%;
  4. left: 50%;
  5. background-color: #000;
  6. transform: translate(-50%,-50%);
  7. border-radius: 50%;
  8. z-index: 10;
  9. animation: youda 3s linear forwards;
  10. }
  11. @keyframes youda{
  12. 0%{
  13. height: 0px;
  14. width: 0px;
  15. }
  16. 100%{
  17. height: 15px;
  18. width: 15px;
  19. }
  20. }

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

  1. .youYu{
  2. position: absolute;
  3. top: 50%;
  4. left: 50%;
  5. transform: translate(-50%,-50%);
  6. }
  7. .quan{
  8. position: absolute;
  9. border-radius: 50%;
  10. border: 2px solid #000;
  11. z-index: calc(1 - var(--r));
  12. animation: zhi 2s ease-out 2s forwards;
  13. }
  14. @keyframes zhi{
  15. 0%{
  16. top: calc(var(--r) * 1px);
  17. left: calc(var(--r) * 1px);
  18. right: calc(var(--r) * 1px);
  19. bottom: calc(var(--r) * 1px);
  20. }
  21. 100%{
  22. top: calc(var(--r) * -35px);
  23. left: calc(var(--r) * -35px);
  24. right: calc(var(--r) * -35px);
  25. bottom: calc(var(--r) * -35px);
  26.  
  27. background-color: rgb(187, 177, 214);
  28. }
  29. }

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

完整代码:

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. *{
  10. margin: 0;
  11. padding: 0;
  12. box-sizing: border-box;
  13. }
  14. body{
  15. height: 100vh;
  16. display: flex;
  17. justify-content: center;
  18. align-items: center;
  19. background-color: #000;
  20. }
  21. .zuo , .you{
  22. width: 250px;
  23. height: 120px;
  24. background-color: rgb(255, 255, 255);
  25. border-bottom: 5px solid rgb(70, 70, 70);
  26. overflow: hidden;
  27. position: relative;
  28. }
  29. .zuo{
  30. transform: translateX(-135px);
  31. border-radius: 0 120px 0 120px;
  32. box-shadow: inset 3px 2px 3px rgba(17, 17, 17, 0.8);
  33. }
  34. .zuo::after{
  35. content: '';
  36. position: absolute;
  37. top: 50%;
  38. left: 50%;
  39. transform: translate(-50%,-50%);
  40. width: 95px;
  41. height: 95px;
  42. border-radius: 50%;
  43. border: 2px solid #000;
  44. animation: colour 2s linear forwards;
  45. }
  46. @keyframes colour{
  47. 0%,30%{
  48. background-color: rgb(0, 0, 0);
  49. }
  50. 100%{
  51. background-color: rgb(255, 4, 4);
  52. }
  53. }
  54.  
  55. .zuoZong{
  56. position: absolute;
  57. top: 50%;
  58. left: 50%;
  59. transform: translate(-50%,-50%);
  60. width: 0px;
  61. height: 0px;
  62. border-radius: 50%;
  63. background-color: rgb(0, 0, 0);
  64. z-index: 1;
  65. animation: da 3s linear forwards;
  66. }
  67. @keyframes da{
  68. 100%{
  69. width: 15px;
  70. height: 15px;
  71. }
  72. }
  73. .zuoYu{
  74. position: absolute;
  75. top: -25px;
  76. left: -25px;
  77. bottom: -25px;
  78. right: -25px;
  79. border-radius: 50%;
  80. border: 2px solid rgb(0, 0, 0);
  81. animation: zhuan 2s linear 2s forwards;
  82. opacity: 0;
  83. }
  84. @keyframes zhuan{
  85. 100%{
  86. opacity: 1;
  87. transform: rotate(720deg);
  88. }
  89. }
  90. .zuoYu .yu{
  91. position: absolute;
  92. width: 15px;
  93. height: 15px;
  94. border-radius: 50%;
  95. background-color: rgb(0, 0, 0);
  96.  
  97. }
  98. .zuoYu .yu::after{
  99. content: '';
  100. position: absolute;
  101. top: -6px;
  102. left: -1px;
  103. width: 6px;
  104. height: 20px;
  105. border-radius: 50%;
  106. border-left: 6px solid rgb(0, 0, 0);
  107. }
  108. .zuoYu .yu:nth-child(1){
  109. animation: yu1 2s ease-in 2s forwards;
  110. }
  111. @keyframes yu1{
  112. 0%{
  113. opacity: 0;
  114. left: 50%;
  115. top: 50%;
  116. transform:translate(-50%,-50%) scale(0.1) ;
  117. }
  118. 100%{
  119. left: 50%;
  120. top: -9%;
  121. transform: scale(1) rotate(80deg);
  122. }
  123. }
  124. .zuoYu .yu:nth-child(2){
  125. animation: yu2 2s ease-in 2s forwards;
  126. }
  127. @keyframes yu2{
  128. 0%{
  129. opacity: 0;
  130. left: 50%;
  131. top: 50%;
  132. transform: translate(-50%,-50%) scale(0.1) ;
  133. }
  134. 100%{
  135. top: 60%;
  136. left: -9%;
  137. transform: scale(1) rotate(-60deg);
  138. }
  139. }
  140. .zuoYu .yu:nth-child(3){
  141. animation: yu3 2s ease-in 2s forwards;
  142. }
  143. @keyframes yu3{
  144. 0%{
  145. opacity: 0;
  146. right: 50%;
  147. top: 50%;
  148. transform: translate(-50%,-50%) scale(0.1);
  149. }
  150. 100%{
  151. top: 60%;
  152. right: -9%;
  153. transform: scale(1) rotate(180deg);
  154. }
  155. }
  156. .zuo::before,.you::before{
  157. content: '';
  158. position: absolute;
  159. left: 38%;
  160. top: 30%;
  161. width: 12px;
  162. height: 12px;
  163. border-radius: 50%;
  164. background-color: rgb(255, 255, 255);
  165. z-index: 10;
  166. }
  167. .you{
  168. transform: translateX(135px);
  169. border-radius: 120px 0 120px 0;
  170. box-shadow: inset -3px 2px 3px rgba(17, 17, 17, 0.8);
  171. /* filter: drop-shadow( 8px -5px 3px rgb(216, 59, 59));
  172. */ }
  173. .you::after{
  174. content: '';
  175. position: absolute;
  176. top: 50%;
  177. left: 50%;
  178. transform: translate(-50%,-50%);
  179. width: 95px;
  180. height: 95px;
  181. border-radius: 50%;
  182. border: 2px solid #000;
  183. animation: youcolor 2s linear forwards;
  184. }
  185. @keyframes youcolor{
  186. 0%,30%{
  187. background-color: rgb(0, 0, 0);
  188. }
  189. 100%{
  190. background-color: rgb(144, 130, 183);
  191. }
  192. }
  193. .dian{
  194. position: absolute;
  195. top: 50%;
  196. left: 50%;
  197. background-color: #000;
  198. transform: translate(-50%,-50%);
  199. border-radius: 50%;
  200. z-index: 10;
  201. animation: youda 3s linear forwards;
  202. }
  203. @keyframes youda{
  204. 0%{
  205. height: 0px;
  206. width: 0px;
  207. }
  208. 100%{
  209. height: 15px;
  210. width: 15px;
  211. }
  212. }
  213. .youYu{
  214. position: absolute;
  215. top: 50%;
  216. left: 50%;
  217. transform: translate(-50%,-50%);
  218. }
  219. .quan{
  220. position: absolute;
  221. border-radius: 50%;
  222. border: 2px solid #000;
  223. z-index: calc(1 - var(--r));
  224. animation: zhi 2s ease-out 2s forwards;
  225. }
  226. @keyframes zhi{
  227. 0%{
  228. top: calc(var(--r) * 1px);
  229. left: calc(var(--r) * 1px);
  230. right: calc(var(--r) * 1px);
  231. bottom: calc(var(--r) * 1px);
  232. }
  233. 100%{
  234. top: calc(var(--r) * -35px);
  235. left: calc(var(--r) * -35px);
  236. right: calc(var(--r) * -35px);
  237. bottom: calc(var(--r) * -35px);
  238.  
  239. background-color: rgb(187, 177, 214);
  240. }
  241. }
  242. </style>
  243. </head>
  244. <body>
  245. <!-- 血轮眼 -->
  246. <div class="zuo">
  247. <!-- 眼睛最中间那个黑点 -->
  248. <div class="zuoZong">
  249. <!-- 三勾玉所在的圈 -->
  250. <div class="zuoYu">
  251. <!-- 三个勾玉 -->
  252. <span class="yu"></span>
  253. <span class="yu"></span>
  254. <span class="yu"></span>
  255. </div>
  256. </div>
  257. </div>
  258. <!-- 轮回眼 -->
  259. <div class="you">
  260. <!-- 眼睛最中间那个黑点 -->
  261. <div class="dian"></div>
  262. <!-- 3个轮回圈 -->
  263. <div class="youYu">
  264. <span class="quan" style="--r:2;"></span>
  265. <span class="quan" style="--r:3;"></span>
  266. <span class="quan" style="--r:4;"></span>
  267. </div>
  268. </div>
  269. </body>
  270. </html>

到此这篇关于html+css实现血轮眼轮回眼特效 的文章就介绍到这了,更多相关html血轮眼轮回眼特效 内容请搜索w3xue以前的文章或继续浏览下面的相关文章,希望大家以后多多支持w3xue!

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号