Changing the DiviMenus Background when hovering Menu Items

Assign a permanent background image to your DiviMenu that changes when hovering over each Menu Item!

This is an advanced tutorial that offers a workaround to achieve something not included by default in the DiviMenus Flex module, so you should implement it carefully and follow the indicated steps.

This is a variation of the previous tutorial “Changing the DiviMenus Background when hovering Menu Items (1)” which was easily achieved by revealing different Divider modules of different colors as backgrounds using the SHOW link type.

However, this time the goal is to reveal different images as the background of the DiviMenu when hovering over Menu Items, while also keeping a different image as the permanent background of the DiviMenu when no Menu Item is being hovered over.

To achieve this, we basically need to add custom code in Page Settings and make some adjustments in the DiviMenus Flex module, which will require each Menu Item to be manually positioned with an absolute position within the Section where you’ll need to define a specific height to your liking.

Follow the steps detailed in the post and… Happy Building! 🥳

SECTION

1. Set Section > Content > Background > Image
2. Set Section > Design > Sizing > Height: 100vh (to your liking)
3. Set Section > Design > Spacing > Padding: 0
4. Set Section > Advanced > CSS Class: dm-bg

ROW

5. Set Row > Design > Sizing > Width / Max Width: 100%

DIVIMENUS FLEX > MENU ITEM

6. Assign to each Menu Item > Advanced > Position > Absolute
7. Paste your background image in each Menu Item > Advanced > Before:

background-image: url('your-image-url.png');

(set your image url)

8. Paste in each Menu Item > Advanced > DiviMenu Menu Item the desired vertical position (H, V), considering that the center would be (-50%, -50%):

transform: translate(-50%, -200%);

(change the vertical value 200% to your liking)

9. Enable “Fullwidth Menu Items” from DiviMenus Flex > Design > DiviMenu.

PAGE SETTINGS

Paste this into Page Settings → Advanced → Custom CSS:
.dm-bg .et_pb_row,
.dm-bg .et_pb_column,
.dm-bg .et_pb_divimenus_flex_item,
.dm-bg .et_pb_module_inner,
.dm-bg .dd-wrapper,
.dm-bg .dd-divimenu {
  height: 100% !important;
}
.dm-bg
.et_pb_divimenus_flex {
  height: 100%;
  width: 100%;
}
.dm-bg .dd-divimenu {
  flex-wrap: nowrap;
}
.dm-bg .et_pb_divimenus_flex_item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.dm-bg .et_pb_module_inner {
  display: flex;
  align-items: center;
}
.dm-bg .dd-wrapper {
  width: 100%;
}
.dm-bg .dd-item {
  position: absolute;
  pointer-events: all!important;
  z-index: 1;
}
.dm-bg
.dd-item.hover {
  z-index: 0!important;
}
.dm-bg
.et_pb_divimenus_flex_item:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  transition: opacity 0.3s ease;
  display: block;
  opacity: 0;
}
.dm-bg .et_pb_divimenus_flex_item:hover:before {
  opacity: 1!important;
}

🥳 That’s it!

DonDivi Gallery - Icon

DonDivi Gallery

Enjoy the ultimate Image Gallery experience in one single module!

👉 Subscribe to our YouTube channel

More Videos