Skip to content

Created a button with a ripple effect using HTML, CSS, and JavaScript. This adds interactivity to the webpage and uses CSS ::before pseudo-elements and transform to create the ripple circle, while JavaScript calculates the position of the user's mouse and updates the CSS custom properties used for the ripple animation.

Notifications You must be signed in to change notification settings

paribhandarkar/button-ripple-effect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Button Ripple Effect

I created a button with a ripple effect using HTML, CSS, and JavaScript. The button has a blue background and a shadow, and when I hover over it, a pink circle expands from the center to create a ripple effect. I used CSS ::before pseudo-elements and transform to create the circle, and JavaScript to calculate the position of the user's mouse and update the CSS custom properties used for the ripple animation. I'm happy with how the button turned out and feel like it adds some interactivity to my webpage.

Demo

You can try out the application by visiting this link.

Technologies Used

  • HTML
  • CSS
  • JavaScript

Getting Started

To get started with this project, clone the repository and open the index.html file in your preferred web browser.

New Things I Learned

I learned a lot from this project! I now understand that pageX and pageY are properties of the MouseEvent object that represent the coordinates of the mouse pointer relative to the entire document, and offsetLeft and offsetTop are properties of an HTML element that represent its position relative to its offset parent.

Additionally, I learned about the setProperty() method, which is used to set custom CSS properties for an element.

Finally, I learned about the mouseover event, which is triggered when the mouse pointer enters an element. Overall, this project was a great learning experience for me.

Challenges I faced

I faced a few challenges while working on this project. Firstly, I had trouble differentiating between the pageX and pageY coordinates, which are relative to the entire document, versus the offsetLeft and offsetTop coordinates, which are relative to an element's offset parent.

Secondly, I struggled to find a way to grab the mouse pointer's position specifically on the button, as opposed to the document as a whole.

Finally, I had some difficulty understanding how to use the setProperty() method to set custom CSS properties for an element.

However, with some research and experimentation, I was able to overcome these challenges and successfully complete the project.

image

About

Created a button with a ripple effect using HTML, CSS, and JavaScript. This adds interactivity to the webpage and uses CSS ::before pseudo-elements and transform to create the ripple circle, while JavaScript calculates the position of the user's mouse and updates the CSS custom properties used for the ripple animation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published