Nguyễn Hữu Hiếu Posted on Jan 20, 2022 4 3 css animation: animate when hover #css #animation Senarior Want to simple animation when hover an element Demo Code <!DOCTYPE html> <html> <head> <style> body { display: flex; justify-content: center; align-items: center; height: 100vh; } div { width: 100px; height: 100px; position: relative; border: solid 2px black; } div:hover { animation: hoverDiv 1s forwards; } @keyframes hoverDiv { 100% { box-shadow: rgba(50, 50, 93, 0.25) 0px 50px 100px -20px, rgba(0, 0, 0, 0.3) 0px 30px 60px -30px; border: solid 2px whitesmoke; } } </style> </head> <body> <div>Hover me</div> </body> </html> Enter fullscreen mode Exit fullscreen mode Top comments (0) Subscribe Personal Trusted User Create template Templates let you quickly answer FAQs or store snippets for re-use. Submit Preview Dismiss Code of Conduct • Report abuse Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)