2.2 KiB
2.2 KiB
Hover Shadow Box Animation
Creates a shadow box around the text whern it is hovered.
HTML
<p class = "hover-shadow-box-animation"> Box it! </p>
CSS
.hover-shadow-box-animation{
display: inline-block;
vertical-align: middle;
transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px transparent;
margin: 10px;
transition-duration: 0.3s;
transition-property: box-shadow, transform;
}
.hover-shadow-box-animation:hover, .hover-shadow-box-animation:focus, .hover-shadow-box-animation:active{
box-shadow: 1px 10px 10px -10px rgba(0,0,24,0.5);
transform: scale(1.2);
}
Demo
Box it!
Explanation
display: inline-blockfor giving width and length forpelement thus making it as aninline-block.- setting the
transform: perspective(1px)for giving element a 3-D space by affecting the distance between the Z plane and the user andtranslate(0)for repositioningpelement along z-axis in 3-D Space. box-shadow:for setting up the box.transparentto make box transparent 5.transition-propertyfor enabling both box-shadow and transform:hoverto activate whole css when hovering is done tillactive.transform: scale(1.2)for changing the scale to 1.2. Now text looks for 1.2 times magnified with shadow Box Effect
Browser Support
✅ No caveats.