• 八种button的hover效果


     CSS八种hover效果,快用起来_哔哩哔哩_bilibili

    以下由于引入了transition所以还需要加兼容性处理:

    -ms-        :/* IE 9 */

    -webkit-        :/* Safari 和 Chrome */

    -moz-        :/* Firefox */

    -o-        :/* Opera */

    1. <!DOCTYPE html>
    2. <html lang="en">
    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. .btn1{
    10. width: 100px;
    11. height: 40px;
    12. color: #fff;
    13. font-size: 20px;
    14. position: relative;
    15. background-color: skyblue;
    16. border: skyblue;
    17. border-radius: 5px;
    18. text-align: right;
    19. padding-right: 20px;
    20. }
    21. .btn1:hover img{
    22. animation: fly 2s ease 1;
    23. }
    24. @keyframes fly {
    25. 0%{
    26. transform: translateX(0);
    27. }
    28. 50%{
    29. transform: translateX(100px);
    30. }
    31. 100%{
    32. transform: translateX(0);
    33. }
    34. }
    35. .btn1 img{
    36. width: 20px;
    37. position: absolute;
    38. top: 10px;
    39. left: 10px;
    40. }
    41. .btn2{
    42. width: 100px;
    43. height: 40px;
    44. color: skyblue;
    45. font-size: 20px;
    46. background-color: transparent;
    47. border-color: skyblue;
    48. border-radius: 5px;
    49. }
    50. .btn2:hover{
    51. background-color: skyblue;
    52. color: #fff;
    53. border: skyblue;
    54. box-shadow: 0 0 99px 20px skyblue;
    55. }
    56. .btn3{
    57. font-size: 20px;
    58. color:blue;
    59. background: transparent;
    60. border: 0;
    61. text-transform: uppercase;
    62. padding: 10px 20px;
    63. box-sizing: border-box;
    64. position: relative;
    65. }
    66. .btn3::before,.btn3::after{
    67. content:"";
    68. box-sizing:inherit;
    69. border: 2px solid transparent;
    70. width: 0%;
    71. height: 0%;
    72. position: absolute;
    73. }
    74. .btn3::before{
    75. top: 0;
    76. left: 0;
    77. }
    78. .btn3::after{
    79. right: 0;
    80. bottom: 0;
    81. }
    82. .btn3:hover::before{
    83. border-top-color:blue;
    84. border-right-color:blue;
    85. transition: width 0.3s ease-out,height 0.3s ease-out 0.3s;
    86. width: 100%;
    87. height: 100%;
    88. }
    89. .btn3:hover::after{
    90. border-bottom-color:blue;
    91. border-left-color: blue;
    92. transition: width 0.3s ease-out 0.6s,height 0.3s ease-out 0.9s;
    93. width: 100%;
    94. height: 100%;
    95. }
    96. #btn4{
    97. width: 150px;
    98. height: 50px;
    99. background-color: #0597eb;
    100. color: #fff;
    101. font-size: 24px;
    102. text-align: center;
    103. line-height: 50px;
    104. border-radius: 25px;
    105. overflow: hidden;
    106. position: relative;
    107. }
    108. #btn4 .sp{
    109. position: absolute;
    110. z-index: 9;
    111. color: red;
    112. }
    113. #btn4::before{
    114. position: absolute;
    115. top: 0;
    116. left: 0;
    117. content: "";
    118. z-index: 0;
    119. width: 0px;
    120. height: 100%;
    121. transition: all 2s ease;
    122. -webkit-transition:all 2s ease;
    123. background-color: #aa00aa;
    124. }
    125. #btn4:hover::before{
    126. width: 200px;
    127. height: 50px;
    128. }
    129. #arrow{
    130. position: absolute;
    131. background-color: #aa00aa;
    132. width: 50px;
    133. height: 50px;
    134. border-radius: 25px;
    135. float: left;
    136. z-index: 9;
    137. }
    138. #arrow span{
    139. float: left;
    140. color: #fff;
    141. }
    142. .btn-container{
    143. position: relative;
    144. }
    145. .btn5{
    146. border: 0;
    147. border-radius: 50px;
    148. color: #fff;
    149. background-color: #5f55af;
    150. padding: 15px 20px 15px 60px;
    151. text-transform: uppercase;
    152. background: linear-gradient(to right,#f72585 50%,#5f55af 50%);
    153. background-size: 200% 100%;
    154. background-position: right bottom;
    155. /* 如果加在 :hover后面,鼠标移出会没有效果 */
    156. transition: all 2s ease;
    157. }
    158. .btn-container span{
    159. background-color: #f72585;
    160. height: 100%;
    161. width: 46px;
    162. position: absolute;
    163. left: 0;
    164. top: 0;
    165. border-radius: 50%;
    166. }
    167. button:hover{
    168. background-position: left bottom;
    169. }
    170. .btn6{
    171. color: #fff;
    172. border: 0;
    173. background-color: #18a6b8;
    174. width: 200px;
    175. height: 50px;
    176. font-size: 24px;
    177. border-radius:10px;
    178. transition: all 2s ease;
    179. }
    180. .btn6:hover{
    181. border-top-left-radius: 50px;
    182. border-bottom-right-radius: 50px;
    183. }
    184. .btn7{
    185. width: 200px;
    186. height: 50px;
    187. background: linear-gradient(to right ,#25aae1,#40e495);
    188. border: 0;
    189. font-size: 24px;
    190. color: #fff;
    191. position: relative;
    192. border-radius: 50px;
    193. overflow: hidden;
    194. }
    195. .btn7::before{
    196. content: "";
    197. width: 0px;
    198. height: 100%;
    199. position: absolute;
    200. top: 0;
    201. left: 0;
    202. background-color: rgba(255,255,255,0.5);
    203. transition:all 2s ease;
    204. }
    205. .btn7:hover::before{
    206. width: 200px;
    207. }
    208. .btn8{
    209. padding: 0;
    210. width: 200px;
    211. height: 50px;;
    212. border: 2px solid #fff;
    213. font-size: 24px;
    214. color: #fff;
    215. background-color: #1B2543;
    216. transition: all 1s ease;
    217. position: relative;
    218. box-sizing: content-box;
    219. overflow: hidden;
    220. }
    221. .btn8::before{
    222. content:'';
    223. width: 20px;
    224. height: 50px;
    225. background-color: rgba(255, 255, 255, 0.1);
    226. transform: skewX(45deg);
    227. transform-origin:0%,0%;
    228. position: absolute;
    229. top: 0px;
    230. left: -45px;
    231. }
    232. .btn8:hover::before{
    233. left: 225px;
    234. transition: all 0.5s linear;
    235. }
    236. .btn9{
    237. width: 200px;
    238. height: 50px;
    239. border: 0;
    240. font-size: 24px;
    241. color: #000;
    242. font-weight: 600;
    243. background:linear-gradient(to right ,#FF765D 50%,#fff 50%);
    244. background-size: 200% 100%;
    245. background-position: right bottom;
    246. transition: all 1s ease;
    247. }
    248. .btn9:hover{
    249. background-position: left bottom;
    250. }
    251. </style>
    252. </head>
    253. <body>
    254. <div id="d1">
    255. <button class="btn1"><img src="flay.webp" alt="纸飞机"> 按钮1 </button>
    256. <button class="btn2">按钮2</button>
    257. <button class="btn3">Hover Me</button>
    258. <div id="btn4"><div id="arrow"><span>-></span></div><span class="sp">Hover Me</span></div>
    259. <div class="btn-container"><span>-></span><button class="btn5">Hover Me</button></div></button>
    260. <button class="btn6">Hover Me</button>
    261. <button class="btn7">Hover Me</button>
    262. <button class="btn8">Hover Me</button>
    263. <button class="btn9">Hover Me</button>
    264. </div>
    265. </body>
    266. </html>

  • 相关阅读:
    OSPF笔记
    kubernetes部署rocketmq集群
    轻量化Backbone | ShuffleNet+ViT结合让ViT也能有ShuffleNet轻量化的优秀能力
    数字零售力航母-看微软如何重塑媒体
    蓝桥杯成绩已出
    【附源码】计算机毕业设计JAVA技术的游戏交易平台
    程序员不撰写代码注释和文档的十大理由
    kubernetes集群安装实战
    .NET -- 使用Dump文件分析异常
    基于Transformer实现英语-->西班牙语的翻译任务
  • 原文地址:https://blog.csdn.net/qq_36582776/article/details/125423888