Warning: session_start(): open(/var/lib/php/fpm/session/sess_krcepdp64lu0869f8h07iuttq3, O_RDWR) failed: Permission denied (13) in /var/www/tst02/wp-content/plugins/wordpress-social-login/wp-social-login.php on line 64

Warning: session_start(): Failed to read session data: files (path: /var/lib/php/fpm/session) in /var/www/tst02/wp-content/plugins/wordpress-social-login/wp-social-login.php on line 64

Notice: Undefined index: HTTP_REFERER in /var/www/tst02/wp-content/themes/mdbootstrap4/inc/cookie-setter.php on line 8
Hover effects - Bootstrap 5 & Material Design 2.0

Hover effects

Hover effects - Bootstrap 5 & Material Design 2.0

MDB hover effect appears when the user positions the computer cursor over an element without activating it. Hover effects make a website more interactive.

However, we don't recommend that you mix hover effects with functional elements (like a drop-down on hover or hidden buttons visible only after hovering) because such an approach isn't mobile-friendly.

MDB is a mobile-first framework, so we attach great importance to making each component easy to use for touch screens.

That's why our hover effects are gentle and decorative.


Basic example

Here is the most common example of hover effects usage - an image changed to link with an additional ripple effect on click.


          <div class="bg-image hover-overlay ripple">
            <img src="https://mdbootstrap.com/img/new/fluid/city/113.jpg" class="img-fluid" />
            <a href="#!">
              <div class="mask" style="background-color: rgba(57, 192, 237, 0.2);"></div>
            </a>
          </div>
        

Types

In MDB there are 3 types of the hover effects: overlay, zoom and shadow.

Overlay

Overlay is an effect that covers with color and defined level of opacity the entire image. The same as with mask you can change the color and opacity by manipulating RGBA code.

Our overlay hover effect relies on masks. Have a look at our masks docs to learn more.

Add .overlay class to the .mask element to apply hover effect. Then manipulate RGBA code to change the color of the overlay.

rgba(18, 102, 241, 0.5)
rgba(178, 60, 253, 0.2)
rgba(0, 183, 74, 0.78)
rgba(249, 49, 84, 0.34)
rgba(251, 251, 251, 0.35)
rgba(57, 192, 237, 0.3)

You can even set a fancy gradient as an overlay.


            <div class="bg-image hover-overlay">
              <img src="https://mdbootstrap.com/img/new/standard/city/053.jpg" class="img-fluid" />
              <div
                class="mask"
                style="
                  background: linear-gradient(
                    45deg,
                    rgba(29, 236, 197, 0.5),
                    rgba(91, 14, 214, 0.5) 100%
                  );
                "
              ></div>
            </div>
          

Zoom

To apply zoom hover effect you have to use slightly different, but simpler syntax.

You only need to add .hover-zoom class to the .bg-image element.


            <div class="bg-image hover-zoom">
              <img src="https://mdbootstrap.com/img/new/standard/city/053.jpg" class="img-fluid" />
            </div>
          

Shadow

Shadow hover effect is even simpler. Simply add .hover-shadow class to any element to apply the effect.


            <img
              src="https://mdbootstrap.com/img/new/standard/city/041.jpg"
              class="img-fluid hover-shadow"
              alt=""
            />
          

Mixing effects

You can freely mix all the effects with each other. However, be careful not to overdo it. MDB adheres to the principle of minimalism and subtlety.


          <div class="bg-image hover-overlay hover-zoom hover-shadow ripple">
            <img src="https://mdbootstrap.com/img/new/fluid/city/113.jpg" class="img-fluid" />
            <a href="#!">
              <div class="mask" style="background-color: rgba(57, 192, 237, 0.2);"></div>
            </a>
          </div>
        

Overlay over mask

If you want to put a text on the image and you need a proper contrast, but still you wish to have hover effect, you can apply overlay on the already existing mask.


          <div class="bg-image ripple" data-ripple-color="light">
            <img src="https://mdbootstrap.com/img/new/standard/city/053.jpg" class="img-fluid" />
            <a href="#!">
              <div class="mask" style="background-color: rgba(0, 0, 0, 0.4);">
                <div class="d-flex justify-content-center align-items-center h-100">
                  <p class="text-white mb-0">Can you see me?</p>
                </div>
              </div>
              <div class="hover-overlay">
                <div class="mask" style="background-color: rgba(251, 251, 251, 0.2);"></div>
              </div>
            </a>
          </div>