如何同时激活按钮个人资料和帖子

How to active button Profile and Posts at the same time?

本文关键字:个人资料 按钮 何同时 激活      更新时间:2023-09-26

如果我在127.0.0.1:8000/posts/我的按钮是"活动"的,但是如果我在127.0.0.1:8000/profile/我的按钮"配置文件"处于活动状态,但按钮"发布"处于非活动状态。

如何同时激活按钮个人资料和帖子?

<div class="container" />
<div class="navbar" />
<div class="navbar-inner" />
<a class="brand {%if request.get_full_path == '/'%} active{%endif%} " href="/">Start</a>
<ul class="nav">
   <li {%if request.get_full_path == '/post/'%}class="active"{%endif%}><a href="/post/">{% trans "Post" %}</a></li>
</ul>

<ul class="nav" />
<li {% if active == 1 %}class="active"{%endif%}><a href="/profile/">{% trans "Profile" %}</a>
</li>
<li {% if active == 2 %}class="active"{%endif%}><a href="/posts/">{% trans "Post" %}</a></li>
....

如果此功能处于活动状态:

<li {% if active == 1 %}class="active"{%endif%}><a href="/profile/">{% trans "Profile" %}</a>

这:

<li {%if request.get_full_path == '/post/'%}class="active"{%endif%}><a href="/post/">{% trans "Post" %}</a></li>

还必须处于活动状态

有一个

if 语句,它为其中一个列表项提供了一个活动的 css 类。if 语句不会使两个按钮都处于活动状态,因为"active"不能同时具有 2 个不同的值。如果由于某种原因两者都需要处于活动状态,则可以删除 if 语句,并将 css 类活动应用于两者。