簡體   English   中英

如何添加菜單以切換引導中的導航欄

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

因此,這就是我要執行的操作,當我的網站處於移動版本(xs)時,在切換導航菜單中添加登錄/注冊(注銷時)和添加配置文件/注銷(登錄時)。 我的網站為台式機版本時,我什么都不想要(sm,md,lg,xl)

我現在有這樣的代碼

<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>

我需要添加

  {% 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 %}

我該怎么做呢? 當它在桌面版本中時,我什么都不想要,我只想在xs中將它們放進去,然后切換到導航菜單

嘗試這個 :

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

另外,作為參考,您可以從Bootstrap視口斷點找到其他選項

希望能幫助到你 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM