我想从https://startbootstrap.com上的模板构建Django CMS模板。
我已加载以下标记
{% load cms_tags menu_tags sekizai_tags staticfiles %}
然后在<body>
部分内的菜单
...
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="#">Start Bootstrap</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
{% show_menu 0 100 100 100 %}
</ul>
</div>
</div>
</nav>
...
不幸的是,菜单中页面的链接几乎没有CSS(见图片)。
基本上,链接必须属于nav-link
类。我该如何解决这个问题?
答案 0 :(得分:3)
您可以为菜单标签使用自定义模板;
<ul class="dropdown">
{% show_menu 1 100 100 100 "partials/navigation.html" %}
</ul>
然后在partials/navigation.html
;
{% load cms_tags menu_tags cache cms_page %}
{% for child in children %}
<li class="nav-link">
<a href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">{{ child.get_menu_title }}</a>
{% if child.children %}
<ul class="sub_menu">
{% show_menu from_level to_level extra_inactive extra_active template '' '' child %}
</ul>
{% endif %}
</li>
{% endfor %}
答案 1 :(得分:0)
<li class="nav-item">
<a class="nav-link" href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">{{ child.get_menu_title }}</a>
{% if child.children %}
<ul class="sub_menu">
{% show_menu from_level to_level extra_inactive extra_active template '' '' child %}
</ul>
{% endif %}
</li>