How To Transition From Transparent Menu Background To White Background

Hello,

I have a site with a transparent header that transitions to a solid color on scroll. I’m using this code for the effect:

.x-bar.x-bar-absolute{
background-color: hsla(0, 0%, 0%, 0) !important;
transition: background 0.8s ease;
}

.x-bar.x-bar-fixed{
background-color: hsla(235, 26%, 21%, 1) !important;
}

However, I also have my menu item backgrounds set to transparent. When the user scrolls, the header changes color but the background of the menu items remains transparent (as it should based on the settings). But I want the background of the menu items to transition from transparent to white upon scrolling. Also, I would like the menu item text to transition from white to black on the same scroll.

Is there a way to do this?

Hi there,

Thanks for writing in! You can try adding the following code in the Theme Options > CSS:

.x-bar.x-bar-fixed .x-anchor {
  background-color: #ffffff !important;
}
.x-bar.x-bar-fixed .x-anchor-text-primary {
  color: #000 !important
}

If you would like to learn CSS, I am sharing few resources that you take a look to get started with CSS and an interesting tool that you can use to speed up the development process.

I recommend you to watch following video that will help you to get started with CSS.

https://www.youtube.com/watch?v=MFR4WXiLzpc

Sometimes it can get a bit difficult to find out the right selector to be able to write the required CSS codes. A handy tool that can help you in this is Google Chrome dev tools. I am sharing the resource that you can refer to get started with dev tools.

https://developers.google.com/web/tools/chrome-devtools/css/

https://developers.google.com/web/tools/chrome-devtools/

https://www.youtube.com/watch?v=tP_kXBJWPhQ&t=200s

Let us know how this goes!

Thanks, but it didn’t work.

There must be another way to do it. I should have mentioned the target of the transition is the sub-menu items…

Hi @zackfiske,

In this case, so that it will not be so confusing, share us a screen shot of what you want to customize with labels and share us also your admin credentials so we could check your full CSS and suggest the best customization to your setup.

Don’t forget to set it in a secure note.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.