Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 306 Vote(s) - 3.64 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is it Possible to Open a Dropdown Menu by Hovering Over a Sibling Element?

#1
I have to make a few changes to the menu of my company's website, including a dropdown menu. The thing is, our website is made with Prestashop, which kind of messed up the hierarchy of the HTML. It pretty much looks like this:
```
<ul class ="menu">
<li>
<a href="" class="sf-with-menu">
<ul class ="submenu">
<li>
<a href="">
</li>
<li>
<a href="">
</li>
</ul>
</li>
</ul>
```

I want to have the `ul` with the class `.submenu` open when I hover on `.sf-with-menu`, which are both at the same level in the page's hierarchy. Is that possible only with CSS? I'm very limited with Prestashop regarding the HTML, since I've read changing the HTML would basically break everything when we update our modules, so I'd like to stick to CSS only if possible.
Reply

#2
I suppose you could use the [`+`](

[To see links please register here]

) selector, which selects "elements that [are] placed immediately after (not inside) the first specified element," like this:

```
<ul class ="menu">
<li>
<a href="" class="sf-with-menu">Anchor</a>
<ul class ="submenu">
<li>
<a href="">One
</li>
<li>
<a href="">Two
</li>
</ul>
</li>
</ul>


<style>
.submenu {
display: none;
}
.sf-with-menu:hover + .submenu {
display: initial;
}
</style>
```

This applies the styles to every instance of `.submenu` placed immediately after `.sf-with-menu`, when hovering over `.sf-with-menu`.

It will only highlight the first instance though, as you can see in this [demo](

[To see links please register here]

), so if you have the structure:

```
.menu
li
.sf-with-menu
.submenu
// stuff in menu
.submenu
// stuff in menu
```

...then only the first `submenu` will be opened on hover.

[![demo][1]][1]

See [here](

[To see links please register here]

) for more CSS info.


[1]:
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through