Що таке випадаючі списки?
Випадаючі меню використовуються в CSS, щоб приховати заздалегідь визначений список у кнопці.
Приклади:
Name One Two Three
Тоді вам слід налаштувати класи в CSS так:
.dropdown { position: relative; display: inline-block; } .dropbtn { background-color: red; padding: 10px; } .dropdown-content { display: none; position: absolute; } .dropdown:hover .dropdown-content { display:block; }
Вам потрібні окремі класи div для створення кнопки, а інший div для відокремлення списку того, що містить кнопка.
Приклад
Content 1 Content 2 × Content 3 Content 4 Content 5
#myNav1 { height: 0; width: 50%; position: fixed; z-index: 6; top: 0; left: 0; background-color: #ffff; overflow: hidden; transition: 0.3s; opacity: 0.85; } #myNav2 { height: 0; width: 50%; position: fixed; z-index: 6; bottom: 0; right: 0; background-color: #ffff; overflow: hidden; transition: 0.3s; opacity: 0.85; } .overlay-content { position: relative; width: 100%; text-align: center; margin-top: 30px; } #myNav1-content{ top: 12%; left: 5%; display: none; } #myNav2-content{ top: 12%; right: 10%; display: none; }
Докладніше про випадаючі списки CSS:
- Як створити випадаюче меню за допомогою CSS та JavaScript