It turns out that in fact the box-shadow
is slow as it needs to be re-drawn throughout the frame during animation, which makes transitions heavier.
The ideal solution to this is to keep a rendered pseudo-element with opacity: 0
and animate this opacity.
.shadow {
display: flex;
align-items: center;
width: 300px;
height: 300px;
margin: 50px;
float: left;
box-sizing: border-box;
padding: 30px;
font-family: sans-serif;
font-size: 18px;
text-align: center;
border-radius: 50px;
}
#slow-transition {
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.3);
transition: box-shadow 500ms;
}
#slow-transition:hover {
box-shadow: 0 10px 50px 0 rgba(0, 0, 0, 0.5);
}
#fast-transition {
position: relative;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.3);
}
#fast-transition::before {
content: ' ';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
border-radius: 50px;
box-shadow: 0 10px 50px 0 rgba(0, 0, 0, 0.5);
opacity: 0;
transition: opacity 500ms;
}
#fast-transition:hover::before {
opacity: 1;
}
<div id="slow-transition" class="shadow">
<p>Box-Shadow normal com transição lenta</p>
</div>
<div id="fast-transition" class="shadow">
<p>Transição rápida da opacidade de pseudo-elemento</p>
</div>
Related but unanswered for more than 2 years... https://answall.com/questions/339175/a-propriedade-de-css-box-shadow-afeta-a-performance-da-p%C3%a1gina-e-renderiza%C3%A7%C3%a3o-dos
– hugocsl
Add your current code so we can test exactly what password you have there, include the minimal html and css so we can simulate your problem
– hugocsl