Are CSS-based menus just switching display none / block and z-index?

Just trying to figure out how to get the drop-down menus to work (the theory behind them). A.

From what I saw, it just plays with CSS, using display: noneand blockalong with z-index.

Events are tied to mouseoverand mouseoutto switch the CSS class.

Is it basically this?

+3
source share
4 answers

There is an alternative here where you can make the display of the visibility of menu items dependent on the hover style of the parent element, for example.

li ul {display: none;}  
li:hover > ul {display: block;}

this means that you can create menus simply using

<ul id="menu">
    <li>
        some item
        <ul><li>sub item</li></ul>
    </li>
    <li>
        some other item
    </li>
<ul>

, , .., , css.

+3

CSS : hover anchor, , mouseover/mouseout.

: , , , : hover , .

+1

horzontal <ul> <li>

- <ul>

.css:

  • <li> "list-style: none", ..

  • <li> "display: inline;"

  • <a> <li> , , "padding: 10px 20px;" ( ), .

+1

, , onmouse (out | over) / , , . , , , . , , - , .

0

Source: https://habr.com/ru/post/1703862/


All Articles