отзывчивый гамбургер navbar не работает в django base.html - PullRequest
0 голосов
/ 10 июня 2019

Я занимаюсь разработкой простого блогового сайта, проблема, с которой я сталкиваюсь, заключается в том, что моя панель навигации не отвечает, ниже моя панель навигации отображается на рабочем столе.

enter image description here

но когда я уменьшаю размер браузера, навигационная панель скрывается

enter image description here

мне нужен значок гамбургера слева вверху, когда я уменьшаю размерпри нажатии на экран все пункты меню навигационной панели должны быть видны вертикально.

enter image description here

ниже - мой код:

{% load static %}

<!doctype html>
<html lang="en">
  <head>
    {% if title %}
    <title>{{ title }}</title>
    {% else %}
    <title>Young Minds</title>
    {% endif %}
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link rel="stylesheet" href="{% static 'blog/css/bootstrap.css' %}">
    <link rel="stylesheet" href="{% static 'blog/css/animate.css' %}">
    <link rel="stylesheet" href="{% static 'blog/css/owl.carousel.min.css' %}">

    <link rel="stylesheet" href="{% static 'blog/fonts/ionicons/css/ionicons.min.css' %}">
    <link rel="stylesheet" href="{% static 'blog/fonts/fontawesome/css/font-awesome.min.css' %}">
    <link rel="stylesheet" href="{% static 'blog/fonts/flaticon/font/flaticon.css' %}">

    <link rel="stylesheet" href="{% static 'blog/css/style.css' %}">
    <link href="https://fonts.googleapis.com/css?family=Hind&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Patrick+Hand&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Merienda&display=swap" rel="stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

    <!-- Theme Style -->


    <!-- jquery functions -->

  </head>
  <body>




      <header role="banner">




        <nav class="navbar navbar-expand-md  navbar-light bg-light">



            <div class="collapse navbar-collapse" id="navbarMenu">
              <ul class="navbar-nav" style="font-family: 'Hind', sans-serif;margin-left:198px;">
                {% with url_name=request.resolver_match.url_name %}

                <li class="nav-item" style="margin-right:15px;margin-left:-20px;">

                  <a class="nav-link active" href="{% url 'blog-home' %}" style="margin-top:-3px;">
                    <span style="font-size: 18px;">Blog </span></a>
                </li>
                <li class="nav-item" style="margin-right:15px;margin-left:88px;">
                  <a class="nav-link" href="{% url 'blog-home' %}">Home</a>
                </li>
                <li class="nav-item dropdown" style="margin-right:15px;">
                  <a class="nav-link dropdown-toggle" href="category.html" id="dropdown04" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Catogery</a>
                  <div class="dropdown-menu" aria-labelledby="dropdown04">
                    {% for category in categories %}


                    <a class="dropdown-item" href="{% url 'category-posts' category.category__category %}">{{category.category__category}}</a>
                    {% endfor %}
                  </div>

                </li>

                <li class="nav-item dropdown {% if url_name == 'index' %}active{% endif %}" style="margin-right:15px;">
                  <a class="nav-link" href="{% url 'about' %}">About Us</a>
                </li>
                {% if user.is_authenticated %}
                <li class="nav-item" style="margin-right:15px;">
                  <a class="nav-link" href="{% url 'profile' user%}">Profile</a>
                </li>

                  <li class="nav-item" style="margin-right:15px;">
                    <a class="nav-link" href="{% url 'post-create' %}">Create Blog</a>
                  </li>
                  <li class="nav-item" style="margin-right:15px;">
                    <a class="nav-link" href="{% url 'user-posts' user %}">My Blogs</a>
                  </li>
                  <li class="nav-item" style="float: left;">
                    <a class="nav-link" href="{% url 'logout' %}" >Logout({{ user.username }})</a>
                  </li>
                {% else %}
                  <li class="nav-item">
                    <a class="nav-link" href="{% url 'login' %}">Login</a>
                  </li>
                  <li class="nav-item">
                    <a class="nav-link" href="{% url 'registration' %}">Signup</a>
                  </li>
                {% endif %}
                {% endwith %}
              </ul>

            </div>
          </div>

      </header>




{% block content%}


{% endblock content%}



<footer class="site-footer">
  <div class="container">
    <div class="row mb-5">
      <div class="col-md-4">
        <h3>Developer's Message</h3>
        <p class="mb-4">

        </p>

        <p>Wish you all a very good day ! Enjoy Blogging ! <i class="fa fa-smile-o" aria-hidden="true"></i></p>
      </div>
      <div class="col-md-6 ml-auto">
        <div class="row">
          <div class="col-md-7">
            <h3>Quick Links</h3>
            <ul class="list-unstyled">
              <li >
                <a  href="{% url 'blog-home' %}">Home</a>
              </li>
              <li><a href="{% url 'about' %}">About</a></li>

              <li class="About"><a href="#categories_jquery">Categories</a></li>
            </ul>

          </div>


            <div class="mb-6">
              <h3>Social</h3>
              <ul class="list-unstyled footer-social">
                <li><a href="#"><span class="fa fa-twitter"></span> Twitter</a></li>
                <li><a href="#"><span class="fa fa-facebook"></span> Facebook</a></li>
                <li><a href="#"><span class="fa fa-instagram"></span> Instagram</a></li>
              </ul>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-md-12 text-center">
        <p class="small">
      <!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
      Copyright &copy; <script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script>document.write(new Date().getFullYear());</script>
      <!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
      </p>
      </div>
    </div>
  </div>
</footer>
<!-- END footer -->



<!-- loader -->

<script src="{% static 'blog/js/jquery-3.2.1.min.js' %}"></script>
<script src="{% static 'blog/js/jquery-migrate-3.0.0.js' %}"></script>
<script src="{% static 'blog/js/popper.min.js' %}"></script>
<script src="{% static 'blog/js/bootstrap.min.js' %}"></script>
<script src="{% static 'blog/js/owl.carousel.min.js' %}"></script>
<script src="{% static 'blog/js/jquery.waypoints.min.js' %}"></script>
<script src="{% static 'blog/js/jquery.stellar.min.js' %}"></script>


<script src="{% static 'blog/js/main.js' %}"></script>

<script type="text/javascript">

$('.reply-btn').click(function(){
  console.log($(this).parent());
  console.log($(this).parent().parent());
  console.log($(this).parent().parent().next());

  $(this).parent().parent().next('.comment-body').fadeToggle()
  console.log("trigerred")

});

$(document).ready(function() {
  $('.About').click(function(event) {
    $("#About-content").toggle("slow");

  });
});

$(document).ready(function(event){
    $(document).on('click',"#like_the_post_by_user", function(event){
      event.preventDefault();
      console.log($("#like_the_post_by_user").val())
      console.log("from jquery section")
      var pk = $(this).attr('value');
      $.ajax({
        type : "POST",
        url : "{% url 'like_post' %}",
        data : {'id': pk , "csrfmiddlewaretoken": '{{ csrf_token }}' },
        dataType : 'json',
        success : function(response){
          $('#like-section_user').html(response['form'])
          console.log($('#like-section_user').html(response['form']));
        },
        error : function(rs, e){
          console.log(rs.responseText);
        }

      });

    });

  });

</script>
</body>
</html>

IПробовал везде искать и тестировать самостоятельно, но я не смог сделать это сам.

Любая помощь будет принята с благодарностью!

Заранее спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...