Menu is a very important component in any website. It is a user interface element within a webpage that contains links to other sections of the website. It can be displayed horizontally or vertically before the main content of the webpage or header.
For Creating Vertical Menu:
- Menus are vertical by default in Pure CSS. It is easy to customize because of minimal default styling and low-specificity selectors.
- All the components of menu should be enclosed within a division with class named "pure-menu".
- Add class "pure-menu-heading" in the <span> element for the main heading or title.
- Then add all the items after heading inside <ul> element with class โpure-menu-listโ. Each item should be enclosed within <li> element with class "pure-menu-item" .
- If you want to link an item with a section of your webpage you can further enclosed it within <a> element with class "pure-menu-link".
Example:
Output:
๐ Image
For creating Horizontal Menu:
You can change the above vertical menu to horizontal menu by just adding the class name "pure-menu-horizontal" in the division at the beginning.
Example:
Output:
๐ Image