提交 43dc0581 编写于 作者: C codecalm

dropdown menu columns rebuild

上级 08a12605
...@@ -155,6 +155,7 @@ extra: ...@@ -155,6 +155,7 @@ extra:
layout: layout:
icon: layout-2 icon: layout-2
title: Layout title: Layout
columns: 2
children: children:
horizontal: horizontal:
url: layout-horizontal.html url: layout-horizontal.html
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
{% assign hide-icons = include.hide-icons %} {% assign hide-icons = include.hide-icons %}
{% assign menu = site.data.menu %} {% assign menu = site.data.menu %}
{% if include.sample %} {% if include.sample %}
{% assign menu = site.data.menu-sample %} {% assign menu = site.data.menu-sample %}
{% endif %} {% endif %}
...@@ -29,9 +30,22 @@ ...@@ -29,9 +30,22 @@
</a> </a>
{% if level-1[1].children %} {% if level-1[1].children %}
<ul class="dropdown-menu{% if level-1[1].right %} dropdown-menu-right{% endif %}{% if level-1[1].columns %} dropdown-menu-columns dropdown-menu-columns-{{ level-1[1].columns }}{% endif %}{% if include.auto-open and level-1[0] == current-page[0] %} show{% endif %}"> <div class="dropdown-menu{% if level-1[1].right %} dropdown-menu-right{% endif %}{% if include.auto-open and level-1[0] == current-page[0] %} show{% endif %}">
{% if level-1[1].columns %}
<div class="dropdown-menu-columns">
{% assign per-column = level-1[1].children | size | times: 1.0 | divided_by: level-1[1].columns | ceil %}
<div class="dropdown-menu-column">
{% endif %}
{% for level-2 in level-1[1].children %} {% for level-2 in level-1[1].children %}
<li {% if level-2[1].children %}class="dropright"{% endif %}>
{% if level-1[1].columns %}
{% assign modulo = forloop.index0 | modulo: per-column %}
{% if forloop.index > 1 and modulo == 0 %}</div><div class="dropdown-menu-column">{% endif %}
{% endif %}
<div {% if level-2[1].children %}class="dropright"{% endif %}>
<a class="dropdown-item{% if level-2[1].children %} dropdown-toggle{% endif %}{% if level-1[0] == current-page[0] and level-2[0] == current-page[1] and current-page.size == 2 %} active{% endif %}" {% if level-2[1].children %}href="#sidebar-{{ level-2[0] }}" data-toggle="dropdown" role="button" aria-expanded="false" {% else %}href="{{ site.base }}/{{ level-2[1].url }}" {% endif %}> <a class="dropdown-item{% if level-2[1].children %} dropdown-toggle{% endif %}{% if level-1[0] == current-page[0] and level-2[0] == current-page[1] and current-page.size == 2 %} active{% endif %}" {% if level-2[1].children %}href="#sidebar-{{ level-2[0] }}" data-toggle="dropdown" role="button" aria-expanded="false" {% else %}href="{{ site.base }}/{{ level-2[1].url }}" {% endif %}>
{{ level-2[1].title }} {{ level-2[1].title }}
</a> </a>
...@@ -43,9 +57,11 @@ ...@@ -43,9 +57,11 @@
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}
</li> </div>
{% endfor %} {% endfor %}
</ul>
{% if level-1[1].columns %}</div></div>{% endif %}
</div>
{% endif %} {% endif %}
</li> </li>
{% endfor %} {% endfor %}
......
...@@ -43,20 +43,16 @@ ...@@ -43,20 +43,16 @@
overflow-x: hidden; overflow-x: hidden;
} }
.dropdown-menu-columns { .dropdown-menu-column {
columns: 2; min-width: 10rem;
column-gap: 0;
.dropdown-item { .dropdown-item {
display: inline-flex; min-width: 0;
min-width: 10rem;
} }
} }
@for $i from 2 through 4 { .dropdown-menu-columns {
.dropdown-menu-columns-#{$i} { display: flex;
columns: $i;
}
} }
.dropdown-menu-arrow { .dropdown-menu-arrow {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册