一.发送效果

HTML

  1. <div id="send-btn">
  2. <button>
  3. // 这里是一个svg的占位
  4. Send
  5. </button>
  6. </div>

CSS

  1. #send-btn{
  2. display: flex;
  3. align-items: center;
  4. justify-content: center;
  5. height: 100vh;
  6. }
  7. button {
  8. background: #5f55af;
  9. border: 0;
  10. border-radius: 5px;
  11. padding: 10px 30px 10px 20px;
  12. color: white;
  13. text-transform: uppercase;
  14. font-weight: bold;
  15. }
  16. button svg {
  17. display: inline-block;
  18. vertical-align: middle;
  19. padding-right: 5px;
  20. }
  21. button:hover svg {
  22. animation: fly 2s ease 1;
  23. }
  24. @keyframes fly {
  25. 0% {
  26. transform: translateX(0%);
  27. }
  28. 50% {
  29. transform: translateX(300%);
  30. }
  31. 100% {
  32. transform: translateX(0);
  33. }
  34. }

GIF图

CSS的hover效果 - 图1

二.霓虹效果

HTML

  1. <div id="neon-btn">
  2. <button class="btn one">Hover me</button>
  3. <button class="btn two">Hover me</button>
  4. <button class="btn three">Hover me</button>
  5. </div>

CSS

  1. #neon-btn {
  2. display: flex;
  3. align-items: center;
  4. justify-content: space-around;
  5. height: 100vh;
  6. background: #031628;
  7. }
  8. .btn {
  9. border: 1px solid;
  10. background-color: transparent;
  11. text-transform: uppercase;
  12. font-size: 14px;
  13. padding: 10px 20px;
  14. font-weight: 300;
  15. }
  16. .one {
  17. color: #4cc9f0;
  18. }
  19. .two {
  20. color: #f038ff;
  21. }
  22. .three {
  23. color: #b9e769;
  24. }
  25. .btn:hover {
  26. color: white;
  27. border: 0;
  28. }
  29. .one:hover {
  30. background-color: #4cc9f0;
  31. -webkit-box-shadow: 10px 10px 99px 6px rgba(76,201,240,1);
  32. -moz-box-shadow: 10px 10px 99px 6px rgba(76,201,240,1);
  33. box-shadow: 10px 10px 99px 6px rgba(76,201,240,1);
  34. }
  35. .two:hover {
  36. background-color: #f038ff;
  37. -webkit-box-shadow: 10px 10px 99px 6px rgba(240, 56, 255, 1);
  38. -moz-box-shadow: 10px 10px 99px 6px rgba(240, 56, 255, 1);
  39. box-shadow: 10px 10px 99px 6px rgba(240, 56, 255, 1);
  40. }
  41. .three:hover {
  42. background-color: #b9e769;
  43. -webkit-box-shadow: 10px 10px 99px 6px rgba(185, 231, 105, 1);
  44. -moz-box-shadow: 10px 10px 99px 6px rgba(185, 231, 105, 1);
  45. box-shadow: 10px 10px 99px 6px rgba(185, 231, 105, 1);
  46. }

GIF图

CSS的hover效果 - 图2

三.边框效果

HTML

  1. <div id="draw-border">
  2. <button>Hover me</button>
  3. </div>

CSS

  1. #draw-border {
  2. display: flex;
  3. align-items: center;
  4. justify-content: center;
  5. height: 100vh;
  6. }
  7. button {
  8. border: 0;
  9. background: none;
  10. text-transform: uppercase;
  11. color: #4361ee;
  12. font-weight: bold;
  13. position: relative;
  14. outline: none;
  15. padding: 10px 20px;
  16. box-sizing: border-box;
  17. }
  18. button::before, button::after {
  19. box-sizing: inherit;
  20. position: absolute;
  21. content: '';
  22. border: 2px solid transparent;
  23. width: 0;
  24. height: 0;
  25. }
  26. button::after {
  27. bottom: 0;
  28. right: 0;
  29. }
  30. button::before {
  31. top: 0;
  32. left: 0;
  33. }
  34. button:hover::before, button:hover::after {
  35. width: 100%;
  36. height: 100%;
  37. }
  38. button:hover::before {
  39. border-top-color: #4361ee;
  40. border-right-color: #4361ee;
  41. transition: width 0.3s ease-out, height 0.3s ease-out 0.3s;
  42. }
  43. button:hover::after {
  44. border-bottom-color: #4361ee;
  45. border-left-color: #4361ee;
  46. transition: border-color 0s ease-out 0.6s, width 0.3s ease-out 0.6s, height 0.3s ease-out 1s;
  47. }

GIF效果

CSS的hover效果 - 图3

四.圆形效果

HTML

  1. <div id="circle-btn">
  2. <div class="btn-container">
  3. // 这里有一个svg元素
  4. <button>Hover me</button>
  5. </div>
  6. </div>

CSS

  1. #circle-btn {
  2. display: flex;
  3. align-items: center;
  4. justify-content: center;
  5. height: 100vh;
  6. }
  7. .btn-container {
  8. position: relative;
  9. }
  10. button {
  11. border: 0;
  12. border-radius: 50px;
  13. color: white;
  14. background: #5f55af;
  15. padding: 15px 20px 16px 60px;
  16. text-transform: uppercase;
  17. background: linear-gradient(to right, #f72585 50%, #5f55af 50%);
  18. background-size: 200% 100%;
  19. background-position: right bottom;
  20. transition:all 2s ease;
  21. }
  22. svg {
  23. background: #f72585;
  24. padding: 8px;
  25. border-radius: 50%;
  26. position: absolute;
  27. left: 0;
  28. top: 0%;
  29. }
  30. button:hover {
  31. background-position: left bottom;
  32. }

GIF图

CSS的hover效果 - 图4

五.圆角效果

HTML

  1. <div id="border-btn">
  2. <button>Hover me</button>
  3. </div>

CSS

  1. #border-btn {
  2. display: flex;
  3. align-items: center;
  4. justify-content: center;
  5. height: 100vh;
  6. }
  7. button {
  8. border: 0;
  9. border-radius: 10px;
  10. background: #2ec4b6;
  11. text-transform: uppercase;
  12. color: white;
  13. font-size: 16px;
  14. font-weight: bold;
  15. padding: 15px 30px;
  16. outline: none;
  17. position: relative;
  18. transition: border-radius 3s;
  19. -webkit-transition: border-radius 3s;
  20. }
  21. button:hover {
  22. border-bottom-right-radius: 50px;
  23. border-top-left-radius: 50px;
  24. border-bottom-left-radius: 10px;
  25. border-top-right-radius: 10px;
  26. }

GIF图

CSS的hover效果 - 图5

六.冰冻效果

HTML

  1. <div id="frozen-btn">
  2. <button class="green">Hover me</button>
  3. <button class="purple">Hover me</button>
  4. </div>

CSS

  1. #frozen-btn {
  2. display: flex;
  3. align-items: center;
  4. justify-content: center;
  5. height: 100vh;
  6. }
  7. button {
  8. border: 0;
  9. margin: 20px;
  10. text-transform: uppercase;
  11. font-size: 20px;
  12. font-weight: bold;
  13. padding: 15px 50px;
  14. border-radius: 50px;
  15. color: white;
  16. outline: none;
  17. position: relative;
  18. }
  19. button:before{
  20. content: '';
  21. display: block;
  22. background: linear-gradient(to left, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0.4) 50%);
  23. background-size: 210% 100%;
  24. background-position: right bottom;
  25. height: 100%;
  26. width: 100%;
  27. position: absolute;
  28. top: 0;
  29. bottom:0;
  30. right:0;
  31. left: 0;
  32. border-radius: 50px;
  33. transition: all 1s;
  34. -webkit-transition: all 1s;
  35. }
  36. .green {
  37. background-image: linear-gradient(to right, #25aae1, #40e495);
  38. box-shadow: 0 4px 15px 0 rgba(49, 196, 190, 0.75);
  39. }
  40. .purple {
  41. background-image: linear-gradient(to right, #6253e1, #852D91);
  42. box-shadow: 0 4px 15px 0 rgba(236, 116, 149, 0.75);
  43. }
  44. .purple:hover:before {
  45. background-position: left bottom;
  46. }
  47. .green:hover:before {
  48. background-position: left bottom;
  49. }

GIF图

CSS的hover效果 - 图6

七.闪亮效果

HTML

  1. <div id="shiny-shadow">
  2. <button><span>Hover me</span></button>
  3. </div>

CSS

  1. #shiny-shadow {
  2. display: flex;
  3. align-items: center;
  4. justify-content: center;
  5. height: 100vh;
  6. background: #1c2541;
  7. }
  8. button {
  9. border: 2px solid white;
  10. background: transparent;
  11. text-transform: uppercase;
  12. color: white;
  13. padding: 15px 50px;
  14. outline: none;
  15. overflow: hidden;
  16. position: relative;
  17. }
  18. span {
  19. z-index: 20;
  20. }
  21. button:after {
  22. content: '';
  23. display: block;
  24. position: absolute;
  25. top: -36px;
  26. left: -100px;
  27. background: white;
  28. width: 50px;
  29. height: 125px;
  30. opacity: 20%;
  31. transform: rotate(-45deg);
  32. }
  33. button:hover:after {
  34. left: 120%;
  35. transition: all 600ms cubic-bezier(0.3, 1, 0.2, 1);
  36. -webkit-transition: all 600ms cubic-bezier(0.3, 1, 0.2, 1);
  37. }

GIF图

CSS的hover效果 - 图7

八.加载效果

HTML

  1. <div id="loading-btn">
  2. <button><span>Hover me</span></button>
  3. </div>

CSS

  1. #loading-btn {
  2. display: flex;
  3. align-items: center;
  4. justify-content: center;
  5. height: 100vh;
  6. }
  7. button {
  8. background: transparent;
  9. border: 0;
  10. border-radius: 0;
  11. text-transform: uppercase;
  12. font-weight: bold;
  13. font-size: 20px;
  14. padding: 15px 50px;
  15. position: relative;
  16. }
  17. button:before {
  18. transition: all 0.8s cubic-bezier(0.7, -0.5, 0.2, 2);
  19. content: '';
  20. width: 1%;
  21. height: 100%;
  22. background: #ff5964;
  23. position: absolute;
  24. top: 0;
  25. left: 0;
  26. }
  27. button span {
  28. mix-blend-mode: darken;
  29. }
  30. button:hover:before {
  31. background: #ff5964;
  32. width: 100%;
  33. }

GIF图

CSS的hover效果 - 图8