Join the Webstudio community

Updated 2 months ago

Is this CSS possible to do natively in Webstudio?

At a glance

The community member is having trouble making a dropdown menu display when hovering over it. They tried using the CSS display: block on the dropdown content when the dropdown is hovered, but it didn't work. Other community members suggest using CSS variables to control the display property. One community member explains the steps: add a variable to the parent element, redefine the variable on the hover state, and then use that variable on the child element's display property. Another community member confirms this approach works and provides an example of using the --display variable.

Action: When I hover the dropdown, the dropdown content is display:

.dropdown:hover .dropdown-content {
display: block;
}

Not sure how to do that. I did dropdown hover, but the dropdown didn't change. I'm sure I miss something. Thank for the help!
1
B
J
M
4 comments
With css variable for display?
@TrySound , yep, that works.

@Milan Boisgard | Uncode School.
  1. Add a var to your parent. (it can be empty)
  2. Redefine the parent var on the hover state
  3. Add var to whatever attribute you wanted on the child
I'm dumb I think John did a very on that. I have to rewatch it. Thanks a lot I gonna try!
I called my variable --display, first I thought I needed to change that variable itself on the child, but I needed to add display and then add that variable to that. As shown in the screenshot. Hope it makes sense 😁
Attachment
image.png
Add a reply
Sign up and join the conversation on Discord