10-13-button-transition.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Button transition</title>
  7. <style>
  8. button {
  9. cursor: pointer;
  10. border: 0;
  11. padding: .5em 1em;
  12. color: #fff;
  13. border-radius: .25em;
  14. outline: none;
  15. font-size: 1em;
  16. background-color: #173b6d;
  17. background-image: -webkit-linear-gradient(top, #1a4a8e, #173b6d);
  18. background-image: linear-gradient(to bottom, #1a4a8e, #173b6d);
  19. box-shadow: 0 .25em 0 rgba(23, 59, 109, 0.3), inset 0 1px 0 rgba(0, 0, 0, 0.3);
  20. -webkit-transition: all 150ms ease-in;
  21. -moz-transition: all 150ms ease-in;
  22. -o-transition: all 150ms ease-in;
  23. transition: all 150ms ease-in;
  24. }
  25. /**
  26. * 1. Note that some touch-based browsers will not apply the :active-state
  27. * on press, so this works best with keyboard or mouse.
  28. */
  29. button:active { /* 1 */
  30. box-shadow: 0 0 0 rgba(23, 59, 109, 0.3), inset 0 1px 0 rgba(0, 0, 0, 0.3);
  31. -webkit-transform: translateY(.25em);
  32. -moz-transform: translateY(.25em);
  33. -o-transform: translateY(.25em);
  34. transform: translateY(.25em);
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <button>Press me!</button>
  40. </body>
  41. </html>