Overview
How to add a mouseover effect to Gutenberg blocks in WordPress. In this article, we will discuss the steps to add Mouseover effect that can be applied to any Gutenberg block level element.
We have already discussed in our previous article how to Add Shadow to Gutenberg blocks in WordPress. After adding Shadow to Gutenberg block element we will apply Mouse over effect to the block element which will come into action when you hover your mouse over the block element.
Prerequisites
Good to have Knowledge
Good to know
Solution
To apply a mouseover effect to Gutenberg blocks in WordPress, you will need to implement a custom class to the block where you want to add a mouseover effect. Please refer to the following article to learn how to add a custom CSS Class.
How to add a custom CSS Class to Gutenberg Block?
In this demonstration, we will apply a class shadow-with-mouse-over-effect to the Gutenberg block element. With the following code, we will be able to add nice Shadow effect to this element.
.shadow-with-mouse-over-effect {
background: #efefef;
box-shadow: 0 0 17px 0 rgba(0,0,0,0.06);
margin-bottom: 30px;
transition: .3s;
}
Where to put Custom CSS code in WordPress?
Most of this code has been clearly explained and discussed in the “how to Add Shadow to Gutenberg blocks in WordPress” article. There are a few differences that we will explain after the following code block that will trigger the nice pull effect when you place your mouse over the element. See closely in the class call, we have a :hover added as a suffix which is a CSS pseudo-class.
.shadow-with-mouse-over-effect:hover {
box-shadow: 0 20px 25px rgba(0,0,0,0.15);
transform: translateY(-4px);
}
What is CSS Transition Property?
CSS transitions help you to manage animation speed when switching CSS properties. Learn More about CSS transitions.
What is CSS Transform Property?
CSS property helps us to rotate, scale, skew or translate an element. Learn More about CSS Transform.
What is CSS :hover?
The :hover is a CSS pseudo-class which triggers when the user hovers the cursor over an element. Learn More
Block Elements with Mouseover effect
The shadow-with-mouse-over-effect class applied and should show you the nice drop shadow effect and should raise when you place your mouse over it. The following image should also show the same effect as it also carries the same CSS class.





[…] Si necesitas recoger la url de la imagen destacada de un bloque, este snippet de hejty te vendrá de perlas, pero si lo que quieres añadir efectos en un bloque al pasar por encima el ratón, en este artículo te cuentan cómo hacerlo. […]
¿Eso fue una pregunta? Por favor, puede volver a publicar en inglés, mi español es robótico (traducido a través de Google)