У меня была такая же проблема, как и у вас. Мне нужна была боковая панель, которую я мог бы использовать в качестве основного меню, с гамбургером при отображении в адаптивном режиме.
Поэтому я переопределил компонент из Bulma (который является боковым меню):
- Я использую версию SASS Bulma
- Я добавил папку
extensions
в сборку Bulma - Я добавил в нее свой
improved_sidebar.sass
файл
Вот мой код, который может быть вам полезен:
// ––––––––––––––––––––––––––––––––––––––––––––––––––
// Aside improvements
// ––––––––––––––––––––––––––––––––––––––––––––––––––
$aside-width: 250px
$aside-right-padding: 30px
$aside-delta: $aside-width - $aside-right-padding
aside
display: block
box-sizing: border-box
position: fixed
top: 0
left: 0
max-width: $aside-width
height: 100%
padding:
top: 10px
bottom: 10px
left: 10px
right: $aside-right-padding
overflow-y: auto
// Initially hidden in mobile mode. Needs to be flagged as "is-active" to be shown
// It will appear OVER the page content
+touch
left: -$aside-delta
&.is-active
left: 0
z-index: 900
// ––––––––––––––––––––––––––––––––––––––––––––––––––
// Clickable burger in mobile mode
// ––––––––––––––––––––––––––––––––––––––––––––––––––
$burger-dimensions: 25px
#aside-burger
display: none
+touch
position: absolute
display: block
top: calc(50% - calc(#{$burger-dimensions} / 2))
right: calc(calc(#{$aside-right-padding} - #{$burger-dimensions}) / 2)
width: $burger-dimensions
height: $burger-dimensions
color: white
i
position: relative
z-index: 1000
font-size: 40px !important
cursor: pointer
&:hover
color: $info
&:active
color: $danger
// Rotate the icon when the sidebar is toggled
aside.is-active
i
transform: rotate(180deg)
// ––––––––––––––––––––––––––––––––––––––––––––––––––
// Utilities
// ––––––––––––––––––––––––––––––––––––––––––––––––––
// The sidebar is natively visible only in desktop
// Therefore we move tagged items to the right, of the same amount
.adjust-with-sidebar
+touch
margin-left: $aside-right-padding
+desktop
margin-left: $aside-width
А вот мой шаблон HTML для (я использую jinja2
и vuejs
для шаблонов):
{% load static %}
<aside class="menu" :class="{'is-active': activeSidebar}">
<div id="aside-burger" @click="activeSidebar = !activeSidebar">
<span class="icon" >
<i class="fas fa-caret-right"></i>
</span>
</div>
<figure class="image has-text-centered">
<a href="{% url 'home' %}">
<img id="menu-logo" src="/media/core/logo.png" alt="Logo">
</a>
</figure>
<p class="menu-label">Exemples</p>
<ul class="menu-list">
<li><a id="example" href="{% url 'example' %}">API Exemple</a></li>
</ul>
<p class="menu-label">Mon Compte</p>
<ul class="menu-list">
<li><a id="account-info" href="{% url 'user_account' %}">Mes informations</a></li>
<li><a id="logout" @click.prevent="submitLogoutForm">Déconnexion</a></li>
</ul>
</aside>