Toggle bootstrap menu is not expanding

Asked

Viewed 165 times

0

My menu with toggle-icon, being used exactly like that of the bootstrap4 example documentation simply does not expand.

I tried that solution but nothing has changed. Currently the code is like this:

<!DOCTYPE html>
{% load staticfiles %}
<html lang="pt-br">
<head>
    <link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="{% static 'js/bootstrap.min.js' %}" type="text/javascript"></script>
    <link rel="stylesheet" href="{% static 'css/giositeapp.css' %}"/>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>G M</title>
</head>
<body>
    <header>
        <nav class="navbar navbar-expand-sm shadow p-4 navbar-dark">
            <a href="#" class="navbar-link">Home</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogg" aria-controls="navbarTogg" aria-expanded="false" aria-label="Alterna navegação">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarTogg">
                <ul class="navbar-nav flex-row ml-sm-auto d-none d-sm-flex">
                    <ul class="navbar-nav mr-auto">
                        <li class="nav-item active">
                            <a href="#" class="nav-link">P</a>
                        </li>
                        <li class="nav-item active">
                            <a href="#" class="nav-link">B</a>
                        </li>
                        <li class="nav-item active">
                            <a href="#" class="nav-link">C</a>
                        </li>
                    </ul>
                </ul>
            </div>
        </nav>
    </header>
    <div class="container">
        {% block content %}
        {% endblock %}
    </div>
</body>

</html>

The tags with {%%} are on account of Django, and apparently not the problem as my custom css file is working normally.

  • Bootstrap 3 or 4 you are using ?

  • Sorry I don’t talk, using 4

  • Initially I tried just linking, but to remove the doubt I downloaded the files and made the references

  • Guy removed the answer because he was looking at his code and it actually seems to be the same BS4. I think the problem should be another...

  • Yes, it is another, but your answer helped me find it. Notice that I have one ul inside the other, the error is in the external ul, it is bugging.

  • I had used this external ul to position part of the items on the right of the screen, but apparently, this also made the toggle work in a dubious way

  • is the d-None over there that prevents it from working, I caught haha

Show 2 more comments

1 answer

1


For the record, the d-none was the problem. It works perfectly as follows (removing it):

<nav class="navbar navbar-expand-sm shadow p-4 navbar-dark">
    <a href="#" class="navbar-link">Home</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogg" aria-controls="navbarTogg" aria-expanded="false" aria-label="Alterna navegação">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarTogg">
        <ul class="navbar-nav flex-row ml-sm-auto d-sm-flex">
            <ul class="navbar-nav mr-auto">
                <li class="nav-item active">
                    <a href="#" class="nav-link">P</a>
                </li>
                <li class="nav-item active">
                    <a href="#" class="nav-link">B</a>
                </li>
                <li class="nav-item active">
                    <a href="#" class="nav-link">C</a>
                </li>
            </ul>
        </ul>
    </div>
</nav>
  • 1

    was that I was thinking that the problem was with the BTN and only then I saw that there was a UL inside another UL and the UL outside had display:None

Browser other questions tagged

You are not signed in. Login or sign up in order to post.