1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-30 00:59:47 +02:00

feat: Mega menu

This commit is contained in:
Phuoc Nguyen
2022-09-22 09:44:29 +07:00
parent fe219f7c79
commit fb543b5cec
7 changed files with 143 additions and 245 deletions

View File

@@ -0,0 +1,11 @@
<div class="mega-menu">
<div class="mega-menu__item">{% rectangle "hor", "sm", 100 %}</div>
<div class="mega-menu__item mega-menu__trigger">
{% rectangle %}
{% triangle "b" %}
<div class="mega-menu__content">
<div class="mega-menu__body">{% lines "hor", 5 %}</div>
</div>
</div>
<div class="mega-menu__item">{% rectangle "hor", "sm", 100 %}</div>
</div>

View File

@@ -131,6 +131,7 @@ eleventyExcludeFromCollections: true
{% pattern "Drawer" %}{% include "covers/drawer.njk" %}{% endpattern %}
{% pattern "Dropdown" %}{% include "covers/dropdown.njk" %}{% endpattern %}
{% pattern "Full screen menu" %}{% include "covers/full-screen-menu.njk" %}{% endpattern %}
{% pattern "Mega menu" %}{% include "covers/mega-menu.njk" %}{% endpattern %}
{% pattern "Menu" %}{% include "covers/menu.njk" %}{% endpattern %}
{% pattern "Pagination" %}{% include "covers/pagination.njk" %}{% endpattern %}
{% pattern "Previous next buttons" %}{% include "covers/previous-next-buttons.njk" %}{% endpattern %}

66
contents/mega-menu.md Normal file
View File

@@ -0,0 +1,66 @@
---
layout: layouts/post.njk
title: Mega menu
description: Create a mega menu with CSS
keywords: css mega menu
---
## HTML
```html
<div class="mega-menu">
<!-- Item -->
<div class="mega-menu__item">...</div>
<!-- An item that triggers displaying the mega menu -->
<div class="mega-menu__item mega-menu__trigger">
<!-- The trigger item's content -->
<div>...</div>
<!-- Mega menu -->
<div class="mega-menu__content">
...
</div>
</div>
<!-- Item -->
<div class="mega-menu__item">...</div>
</div>
```
## CSS
```css
.mega-menu {
/* Used to position the mega menu */
position: relative;
}
.mega-menu__trigger:hover .mega-menu__content {
/* Show the mega menu when hovering the trigger item */
display: block;
}
.mega-menu__content {
/* Border */
border: 1px solid #d1d5db;
margin-top: -1px;
/* Hidden by default */
display: none;
/* Absolute position */
left: 0px;
position: absolute;
top: 100%;
/* Take full width */
width: 100%;
/* Displayed on top of other elements */
background: #fff;
z-index: 9999;
}
```
{% demo %}{% include "covers/mega-menu.njk" %}{% enddemo %}