Creative Button Styles

CreativeButtons.zip

antd bnutton

https://code.juejin.cn/pen/7112314290681413662
image.png

阴影按钮

image.png

  1. .btn {
  2. color: inherit;
  3. cursor: pointer;
  4. display: inline-block;
  5. text-transform: uppercase;
  6. letter-spacing: 1px;
  7. font-weight: 700;
  8. position: relative;
  9. box-shadow: rgb(218, 150, 34) 0px 5px;
  10. font-size: 20px;
  11. height: 50px;
  12. width: 220px;
  13. line-height: 50px;
  14. -webkit-tap-highlight-color: transparent;
  15. border-width: initial;
  16. border-style: none;
  17. border-color: initial;
  18. border-image: initial;
  19. margin: 10px 30px;
  20. outline: 0px;
  21. background: rgb(252, 173, 38);
  22. border-radius: 7px;
  23. color: #fff;
  24. }
  25. <button class="btn">按钮</button>

鼠标光标渐变跟踪

  1. <button class="mouse-cursor-gradient-tracking">
  2. <span>Hover me</span>
  3. </button>
  4. .mouse-cursor-gradient-tracking {
  5. position: relative;
  6. background: #7983ff;
  7. padding: 0.5rem 1rem;
  8. font-size: 1.2rem;
  9. border: none;
  10. color: white;
  11. cursor: pointer;
  12. outline: none;
  13. overflow: hidden;
  14. }
  15. .mouse-cursor-gradient-tracking span {
  16. position: relative;
  17. }
  18. .mouse-cursor-gradient-tracking::before {
  19. --size: 0;
  20. content: '';
  21. position: absolute;
  22. left: var(--x);
  23. top: var(--y);
  24. width: var(--size);
  25. height: var(--size);
  26. background: radial-gradient(circle closest-side, pink, transparent);
  27. transform: translate(-50%, -50%);
  28. transition: width 0.2s ease, height 0.2s ease;
  29. }
  30. .mouse-cursor-gradient-tracking:hover::before {
  31. --size: 200px;
  32. }
  33. var btn = document.querySelector('.mouse-cursor-gradient-tracking')
  34. btn.onmousemove = function(e) {
  35. var x = e.pageX - btn.offsetLeft
  36. var y = e.pageY - btn.offsetTop
  37. btn.style.setProperty('--x', x + 'px')
  38. btn.style.setProperty('--y', y + 'px')
  39. }

image.png

注意!
如果元素的父级具有定位上下文(position: relative ),您还需要减去它的偏移量。

  1. var x = e.pageX - btn.offsetLeft - btn.offsetParent.offsetLeft
  2. var y = e.pageY - btn.offsetTop - btn.offsetParent.offsetTop

气泡动画按钮

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>按钮点击气泡效果-jq22.com</title>
  6. <script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
  7. <style>
  8. body {
  9. font-size:16px;
  10. font-family:'Helvetica','Arial',sans-serif;
  11. text-align:center;
  12. background-color:#f8faff;
  13. }
  14. .bubbly-button {
  15. font-family:'Helvetica','Arial',sans-serif;
  16. display:inline-block;
  17. font-size:1em;
  18. padding:1em 2em;
  19. margin-top:100px;
  20. margin-bottom:60px;
  21. -webkit-appearance:none;
  22. appearance:none;
  23. background-color:#ff3de8;
  24. color:#fff;
  25. border-radius:4px;
  26. border:none;
  27. cursor:pointer;
  28. position:relative;
  29. transition:transform ease-in 0.1s,box-shadow ease-in 0.25s;
  30. box-shadow:0 2px 15px rgba(255,0,251,0.5);
  31. }
  32. .bubbly-button:focus {
  33. outline:0;
  34. }
  35. .bubbly-button:before,.bubbly-button:after {
  36. position:absolute;
  37. content:'';
  38. display:block;
  39. width:140%;
  40. height:100%;
  41. left:-20%;
  42. z-index:-1000;
  43. transition:all ease-in-out 0.5s;
  44. background-repeat:no-repeat;
  45. }
  46. .bubbly-button:before {
  47. display:none;
  48. top:-75%;
  49. background-image:radial-gradient(circle,#ff0081 20%,transparent 20%),radial-gradient(circle,transparent 20%,#ff0081 20%,transparent 30%),radial-gradient(circle,#ff0081 20%,transparent 20%),radial-gradient(circle,#ff0081 20%,transparent 20%),radial-gradient(circle,transparent 10%,#ff0081 15%,transparent 20%),radial-gradient(circle,#ff0081 20%,transparent 20%),radial-gradient(circle,#ff0081 20%,transparent 20%),radial-gradient(circle,#ff0081 20%,transparent 20%),radial-gradient(circle,#ff0081 20%,transparent 20%);
  50. background-size:10% 10%,20% 20%,15% 15%,20% 20%,18% 18%,10% 10%,15% 15%,10% 10%,18% 18%;
  51. }
  52. .bubbly-button:after {
  53. display:none;
  54. bottom:-75%;
  55. background-image:radial-gradient(circle,#ff0081 20%,transparent 20%),radial-gradient(circle,#ff0081 20%,transparent 20%),radial-gradient(circle,transparent 10%,#ff0081 15%,transparent 20%),radial-gradient(circle,#ff0081 20%,transparent 20%),radial-gradient(circle,#ff0081 20%,transparent 20%),radial-gradient(circle,#ff0081 20%,transparent 20%),radial-gradient(circle,#ff0081 20%,transparent 20%);
  56. background-size:15% 15%,20% 20%,18% 18%,20% 20%,15% 15%,10% 10%,20% 20%;
  57. }
  58. .bubbly-button:active {
  59. transform:scale(0.9);
  60. background-color:#e60074;
  61. box-shadow:0 2px 25px rgba(255,0,130,0.2);
  62. }
  63. .bubbly-button.animate:before {
  64. display:block;
  65. animation:topBubbles ease-in-out 0.75s forwards;
  66. }
  67. .bubbly-button.animate:after {
  68. display:block;
  69. animation:bottomBubbles ease-in-out 0.75s forwards;
  70. }
  71. @keyframes topBubbles {
  72. 0% {
  73. background-position:5% 90%,10% 90%,10% 90%,15% 90%,25% 90%,25% 90%,40% 90%,55% 90%,70% 90%;
  74. }
  75. 50% {
  76. background-position:0% 80%,0% 20%,10% 40%,20% 0%,30% 30%,22% 50%,50% 50%,65% 20%,90% 30%;
  77. }
  78. 100% {
  79. background-position:0% 70%,0% 10%,10% 30%,20% -10%,30% 20%,22% 40%,50% 40%,65% 10%,90% 20%;
  80. background-size:0% 0%,0% 0%,0% 0%,0% 0%,0% 0%,0% 0%;
  81. }
  82. }@keyframes bottomBubbles {
  83. 0% {
  84. background-position:10% -10%,30% 10%,55% -10%,70% -10%,85% -10%,70% -10%,70% 0%;
  85. }
  86. 50% {
  87. background-position:0% 80%,20% 80%,45% 60%,60% 100%,75% 70%,95% 60%,105% 0%;
  88. }
  89. 100% {
  90. background-position:0% 90%,20% 90%,45% 70%,60% 110%,75% 80%,95% 70%,110% 10%;
  91. background-size:0% 0%,0% 0%,0% 0%,0% 0%,0% 0%,0% 0%;
  92. }
  93. }</style>
  94. </head>
  95. <body>
  96. <button class="bubbly-button">点击气泡动画</button>
  97. <script>
  98. var animateButton = function(e) {
  99. e.preventDefault;
  100. // reset animation 复位动画
  101. e.target.classList.remove('animate');
  102. e.target.classList.add('animate');
  103. setTimeout(function() {
  104. e.target.classList.remove('animate');
  105. }, 700);
  106. };
  107. var btn = document.getElementsByClassName("bubbly-button");
  108. for (var i = 0; i < btn.length; i++) {
  109. btn[i].addEventListener('click', animateButton, false);
  110. }
  111. </script>
  112. </body>
  113. </html>

点击查看【codepen】

霓虹按钮

  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">
  7. <title></title>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. box-sizing: border-box;
  13. font-family: "Poppins", sans-serif;
  14. }
  15. html,
  16. body {
  17. display: grid;
  18. height: 100%;
  19. place-items: center;
  20. background: #000;
  21. overflow: hidden;
  22. }
  23. button {
  24. position: relative;
  25. height: 60px;
  26. width: 200px;
  27. margin: 0 35px;
  28. border-radius: 50px;
  29. border: none;
  30. outline: none;
  31. background: #111;
  32. color: #fff;
  33. font-size: 20px;
  34. letter-spacing: 2px;
  35. text-transform: uppercase;
  36. cursor: pointer
  37. }
  38. button:first-child:hover {
  39. background: linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);
  40. background-size: 400%;
  41. }
  42. button:last-child:hover {
  43. background: linear-gradient(90deg, #fa7199, #f5ce62, #e43603, #fa7199);
  44. background-size: 400%;
  45. }
  46. button:first-child:before,
  47. button:last-child:before {
  48. content: '';
  49. position: absolute;
  50. background: inherit;
  51. top: -5px;
  52. right: -5px;
  53. bottom: -5px;
  54. left: -5px;
  55. border-radius: 50px;
  56. filter: blur(20px);
  57. opacity: 0;
  58. transition: opacity 0.5s;
  59. }
  60. button:first-child:hover:before,
  61. button:last-child:hover:before {
  62. opacity: 1;
  63. z-index: -1;
  64. }
  65. button:hover {
  66. z-index: 1;
  67. animation: glow 8s linear infinite;
  68. }
  69. @keyframes glow {
  70. 0% {
  71. background-position: 0%;
  72. }
  73. 100% {
  74. background-position: 400%;
  75. }
  76. }
  77. </style>
  78. </head>
  79. <body>
  80. <div class="buttons">
  81. <button>Button</button>
  82. <button>Button</button>
  83. </div>
  84. </body>
  85. </html>

image.png