Advertisement
afsarwebdev

JS Button style wave view

Jul 8th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. //Html markup
  2. <button class="cr-btn"><span>Subscribe now</span></button>
  3. //CSS
  4.  
  5. .cr-btn {
  6. position: relative;
  7. overflow: hidden;
  8. border: 1px solid pink;
  9. background-color: pink;
  10. color: #fff;
  11. padding: 10px 20px;
  12. }
  13. .cr-btn span {
  14. z-index: 2;
  15. color: #fff;
  16. position: relative;
  17. }
  18. a.cr-btn b,
  19. button.cr-btn b {
  20. background: rgba(25, 25, 25, 1) none repeat scroll 0 0;
  21. border-radius: 50%;
  22. bottom: 0;
  23. display: block;
  24. height: 0;
  25. left: 0;
  26. position: absolute;
  27. right: 0;
  28. top: 0;
  29. transform: translate(-50%, -50%);
  30. transition: width 0.6s ease-in-out 0s, height 0.6s ease-in-out 0s;
  31. width: 0;
  32. z-index: 1;
  33. }
  34. a.cr-btn:hover b,
  35. button.cr-btn:hover b {
  36. height: 500px;
  37. width: 500px;
  38. }
  39. //Js
  40. function buttonEffect() {
  41. $('<b></b>').appendTo('.cr-btn');
  42. $('.cr-btn')
  43. .on('mouseenter', function(e) {
  44. var parentOffset = $(this).offset(),
  45. relX = e.pageX - parentOffset.left,
  46. relY = e.pageY - parentOffset.top;
  47. $(this).find('b').css({
  48. top: relY,
  49. left: relX
  50. });
  51. })
  52. .on('mouseout', function(e) {
  53. var parentOffset = $(this).offset(),
  54. relX = e.pageX - parentOffset.left,
  55. relY = e.pageY - parentOffset.top;
  56. $(this).find('b').css({
  57. top: relY,
  58. left: relX
  59. });
  60. });
  61. $('[href="#"]').on('click', function() {
  62. return true;
  63. });
  64. }
  65. buttonEffect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement