简体   繁体   English

如何添加菜单以切换引导中的导航栏

[英]how to add menu to toggle navigation bar in bootstrap

So here's what I want to do, add login/signup(when logged out) add profile/logout(when logged in) in toggle navigation menu when my web is in mobile version(xs). 因此,这就是我要执行的操作,当我的网站处于移动版本(xs)时,在切换导航菜单中添加登录/注册(注销时)和添加配置文件/注销(登录时)。 I don't want anything when my web is in desktop version(sm,md, lg, xl) 我的网站为台式机版本时,我什么都不想要(sm,md,lg,xl)

I have code like this right now 我现在有这样的代码

<nav class="navbar navbar-default navbar-static-top" role="navigation">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="{% url 'index' %}">MyWeb</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">


      </ul>

I need to add 我需要添加

  {% if user.is_authenticated %}
<a href="{% url 'userena_profile_detail' user.username %}" style="color:white">profile<i class="fa fa-user"></i></a></li>
    <li><a href="/accounts/signout" style="position:relative; right:15px; color:white">else</a>
{% else %}
    <li><a href="/accounts/signup/"style="color:white">signin<i class="fa fa-registered"></i></a></li>
    <li><a href="/accounts/signin/" style="position:relative; right:15px; color:white">login<i class="fa fa-sign-in"></i></a></li>

    {% endif %}

how do I do this? 我该怎么做呢? I don't want anything when it's in desktop version, I just want to simply put these when it's in xs and I get toggle nav menu 当它在桌面版本中时,我什么都不想要,我只想在xs中将它们放进去,然后切换到导航菜单

Try this : 尝试这个 :

<nav class="navbar navbar-default visible-xs-block">

Also, for your reference you can find other option from Bootstrap viewport breakpoints 另外,作为参考,您可以从Bootstrap视口断点找到其他选项

Hope it helps :) 希望能帮助到你 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM