CSS特效002:花样的鼠标悬停效果

柔情只为你懂 2024-02-19 09:14 121阅读 0赞

GPT能够很好的应用到我们的代码开发中,能够提高开发速度。你可以利用其代码,做出一定的更改,然后实现效能。

css实战中,鼠标的悬停有各种各样的效果,下面的这个示例集中了填充、脉搏抖动,关闭,提升,向上填充,来门,错位等各种花样特效,很炫酷实用

效果图

在这里插入图片描述

源代码

  1. /*
  2. * @Author: 大剑师兰特(xiaozhuanlan),还是大剑师兰特(CSDN)
  3. * @此源代码版权归大剑师兰特所有,可供学习或商业项目中借鉴,未经授权,不得重复地发表到博客、论坛,问答,git等公共空间或网站中。
  4. * @Email: 2909222303@qq.com
  5. * @weixin: gis-dajianshi
  6. * @First published in CSDN
  7. * @First published time: 2023-11-08
  8. */
  9. <template>
  10. <div class="container">
  11. <div class="top">
  12. <h3>花样的鼠标悬停特效</h3>
  13. <div class="author">大剑师兰特, 还是大剑师兰特,gis-dajianshi</div>
  14. </div>
  15. <div style="width:640px ; margin:0 auto; background:#222222;">
  16. <button class="fill">Fill In</button>
  17. <button class="pulse">Pulse</button>
  18. <button class="close">Close</button>
  19. <button class="raise">Raise</button>
  20. <button class="up">Fill Up</button>
  21. <button class="slide">Slide</button>
  22. <button class="offset">Offset</button>
  23. </div>
  24. </div>
  25. </template>
  26. <style scoped>
  27. .container {
  28. width: 1000px;
  29. height: 580px;
  30. margin: 50px auto;
  31. border: 1px solid green;
  32. position: relative;
  33. }
  34. .top {
  35. margin: 0 auto 130px;
  36. padding: 10px 0;
  37. background: mediumpurple;
  38. color: #fff;
  39. }
  40. .fill:hover,
  41. .fill:focus {
  42. box-shadow: inset 0 0 0 2em var(--hover);
  43. }
  44. .pulse:hover,
  45. .pulse:focus {
  46. -webkit-animation: pulse 1s;
  47. animation: pulse 1s;
  48. box-shadow: 0 0 0 2em rgba(255, 255, 255, 0);
  49. }
  50. @-webkit-keyframes pulse {
  51. 0% {
  52. box-shadow: 0 0 0 0 var(--hover);
  53. }
  54. }
  55. @keyframes pulse {
  56. 0% {
  57. box-shadow: 0 0 0 0 var(--hover);
  58. }
  59. }
  60. .close:hover,
  61. .close:focus {
  62. box-shadow: inset -3.5em 0 0 0 var(--hover), inset 3.5em 0 0 0 var(--hover);
  63. }
  64. .raise:hover,
  65. .raise:focus {
  66. box-shadow: 0 0.5em 0.5em -0.4em var(--hover);
  67. -webkit-transform: translateY(-0.25em);
  68. transform: translateY(-0.25em);
  69. }
  70. .up:hover,
  71. .up:focus {
  72. box-shadow: inset 0 -3.25em 0 0 var(--hover);
  73. }
  74. .slide:hover,
  75. .slide:focus {
  76. box-shadow: inset 6.5em 0 0 0 var(--hover);
  77. }
  78. .offset {
  79. box-shadow: 0.3em 0.3em 0 0 var(--color), inset 0.3em 0.3em 0 0 var(--color);
  80. }
  81. .offset:hover,
  82. .offset:focus {
  83. box-shadow: 0 0 0 0 var(--hover), inset 6em 3.5em 0 0 var(--hover);
  84. }
  85. .fill {
  86. --color: #a972cb;
  87. --hover: #cb72aa;
  88. }
  89. .pulse {
  90. --color: #ef6eae;
  91. --hover: #ef8f6e;
  92. }
  93. .close {
  94. --color: #ff7f82;
  95. --hover: #ffdc7f;
  96. }
  97. .raise {
  98. --color: #ffa260;
  99. --hover: #e5ff60;
  100. }
  101. .up {
  102. --color: #e4cb58;
  103. --hover: #94e458;
  104. }
  105. .slide {
  106. --color: #8fc866;
  107. --hover: #66c887;
  108. }
  109. .offset {
  110. --color: #19bc8b;
  111. --hover: #1973bc;
  112. }
  113. button {
  114. color: var(--color);
  115. -webkit-transition: 0.25s;
  116. transition: 0.25s;
  117. }
  118. button:hover,
  119. button:focus {
  120. border-color: var(--hover);
  121. color: #fff;
  122. }
  123. button {
  124. background: none;
  125. border: 2px solid;
  126. font: inherit;
  127. line-height: 1;
  128. margin: 0.5em;
  129. padding: 1em 2em;
  130. }
  131. </style>

发表评论

表情:
评论列表 (有 0 条评论,121人围观)

还没有评论,来说两句吧...

相关阅读

    相关 CSS鼠标悬停

    > 在学习中遇到许多好看的样式,虽然只是用HTML+CSS简单的实现,仅作为我的学习笔记和同爱好学习者的分享: 先看效果 ![这里写图片描述][70] HTM