下拉式引导程序可移动我的导航栏中的所有项目

我已经为我的网站创建了一个导航栏。但是我不太了解如何使用引导程序定位项目。我有一个问题,当我单击下拉按钮(配置文件图像)时,导航栏上的所有项目都移动了,而我不希望这样:

https://www.codeply.com/p/OlyRp40cOH

HTML:

<div class="pos-f-t"> 
    <nav class="navbar fixed-top navbar-custom" style="height: 80px;">
        <button class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent"
            aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <a class="navbar-brand" href="#">
            <img src="assets/img/logo.png" alt="LOGO" style="height: 50px"> Title
        </a>
        <form class="mx-2 my-auto d-inline w-50">
            <input class="form-control mr-sm-6" type="search" placeholder="Search..." aria-label="Search" id="searchBar">
        </form>
        <ul class="navbar-nav ml-auto">
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown"
                  aria-haspopup="true" aria-expanded="false">
                    <img src="https://mdbootstrap.com/img/Photos/Avatars/avatar-2.jpg" class="rounded-circle z-depth-0"
                    alt="avatar image" style="height: 50px; outline-width: 10px; outline-color: white">
                </a>
                <div class="dropdown-menu"
                    aria-labelledby="navbarDropdownMenuLink">
                    <a class="dropdown-item" href="#">My account</a>
                    <a class="dropdown-item" href="#">Disconnect</a>
                </div>
            </li>
        </ul>
    </nav>
</div>

CSS:

    .navbar-custom { 
        background-color: #2c3e50; 
        color: white;
        font-weight: bold; 
        font-variant-caps: small-caps;
    }
    .navbar-toggler-icon {
        background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255,255,255, 1)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");
    }
    .navbar-toggler-icon:hover {
        background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255,176,43, 1)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");
    }
    .navbar-brand {
        margin-left: 2%; 
        font-size: 30px; 
        color: white
    }
    .navbar-brand:hover {
        color: #ffb02b;
    }
    #searchBar {
        border-radius: 20px;
        font-family:Arial, 'Font Awesome 5 Free'
    }
    #searchBar:focus {
        border-color: #ffb02b;
        border-width: 2px;
    }
评论
  • ket
    ket 回复

    您在使用“ nav”更改该类时遇到“ navbar-nav”类的问题

    enter code here <ul class="nav ml-auto">