|
| 1 | +# Dropdown documentation |
| 2 | + |
| 3 | +This part of the documentation will show you how to use the<br> |
| 4 | +included dropdown menus of ChocolateCSS. |
| 5 | + |
| 6 | +# Basic usage |
| 7 | + |
| 8 | +Using single page dropdown menus with ChocolateCSS is very easy. |
| 9 | + |
| 10 | +```html |
| 11 | +<div class="dropdown dropdown-dark active"> |
| 12 | + <div class="dropdown-menu"> |
| 13 | + <div class="dropdown-menu-item">Item 1</div> |
| 14 | + <div class="dropdown-menu-item">Item 2</div> |
| 15 | + </div> |
| 16 | +</div> |
| 17 | +``` |
| 18 | + |
| 19 | +The other `div` tag contains three classes. The `dropdown` class defines the general structure of the dropdown.<br> |
| 20 | +The `dropdown-dark` class defines the theme of the dropdown. |
| 21 | +There are three different themes available. |
| 22 | + |
| 23 | +- `dropdown-light` |
| 24 | +- `dropdown-grey` |
| 25 | +- `dropdown-dark` |
| 26 | + |
| 27 | +The `active` class sets the visibility of the dropdown. `active` means, that the dropdown fades in from the top. |
| 28 | + |
| 29 | +Into the other `div` you will have to put a div with the class `dropdown-menu`. Into this you can put your menu elements.<br> |
| 30 | +To define a menu element, you need to put a div into your menu `div` and add another `div` with the class `dropdown-menu-item`. |
| 31 | + |
| 32 | +# Multiple menus |
| 33 | + |
| 34 | +Multiple menus in one dropdown menu are also possible. |
| 35 | + |
| 36 | +```html |
| 37 | +<div class="dropdown dropdown-dark active"> |
| 38 | + <div class="dropdown-menu" id="main-menu"> |
| 39 | + <div class="dropdown-menu-item" onclick="DropdownForwardMenu('main-menu', 'sec-menu');">Item 1</div> |
| 40 | + <div class="dropdown-menu-item">Item 2</div> |
| 41 | + </div> |
| 42 | + <div class="dropdown-submenu" id="sec-menu"> |
| 43 | + <div class="dropdown-menu-item" onclick="DropdownBackwardMenu('sec-menu', 'main-menu');">Item 3</div> |
| 44 | + <div class="dropdown-menu-item">Item 4</div> |
| 45 | + </div> |
| 46 | +</div> |
| 47 | +``` |
| 48 | + |
| 49 | +To get multiple menus in one dropdown to work, you will have to add the `dropdown-toggler.js` script to your html body. |
| 50 | + |
| 51 | +```html |
| 52 | +<script src="js/dropdown-toggler.js"></script> |
| 53 | +``` |
| 54 | + |
| 55 | +After that you can go on with adding a submenu.<br> |
| 56 | +The structure of the submenu is equal to the structure of |
| 57 | +default dropdown menu. Just change the class to `dropdown-submenu`. |
| 58 | + |
| 59 | +```html |
| 60 | +<div class="dropdown-submenu"> |
| 61 | + <div class="dropdown-menu-item">Item 3</div> |
| 62 | + <div class="dropdown-menu-item">Item 4</div> |
| 63 | +</div> |
| 64 | +``` |
| 65 | + |
| 66 | +Your submenu is hidden now.<br> |
| 67 | +To make them callable, you will need to add an id to every menu (Look main example). |
| 68 | + |
| 69 | +Check out the <a href="./scripts.md">script documentation</a> to learn how to toggle between the different menus of the dropdown. |
0 commit comments