Bootstrap 导航栏中的下拉菜单出现问题

qjp7pelc  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(1)|浏览(225)

screenshot我希望下拉菜单不与导航栏中的其他项目重叠。如何将下拉菜单项偏移到导航栏下方。

<!DOCTYPE html>
    <html>
        <head>
            <title>Little Lemon Restaurant</title>
            <link rel="stylesheet" href="istyle.css">
            <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">
            <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8" crossorigin="anonymous"></script>
        </head>
        <body>
            <nav class="navbar navbar-expand-md bg-light">
                <div class="container-fluid">
                    
                    <form class="d-flex" role="search">
                        <input class="form-control me-2" type="search" placeholder="Search">
                        <button class="btn btn-outline-primary" type="submit">Search</button>
                    </form>
                    <div class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle mx-2" href="#" role="button" data-bs-toggle="dropdown">
                            Follow us
                        </a>
                        <ul class="dropdown-menu dropdown-menu-end">
                          <li><a class="dropdown-item" href="#">Facebook</a></li>
                          <li><a class="dropdown-item" href="#">Instagram</a></li>
                          <li><hr class="dropdown-divider"></li>
                          <li><a class="dropdown-item" href="#">Something else here</a></li>
                        </ul>
                    </div>
                </div>
            </nav>
        </body>
    </html>
vbkedwbf

vbkedwbf1#

尝试将mt-3类添加到ul标记:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Little Lemon Restaurant</title>
        <link rel="stylesheet" href="istyle.css">
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8" crossorigin="anonymous"></script>    
</head>
<body>  
        <nav class="navbar navbar-expand-md bg-light">
            <div class="container-fluid">
                
                <form class="d-flex" role="search">
                    <input class="form-control me-2" type="search" placeholder="Search">
                    <button class="btn btn-outline-primary" type="submit">Search</button>
                </form>
                <div class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle mx-2" href="#" role="button" data-bs-toggle="dropdown">
                        Follow us
                    </a>
                    <ul class="mt-3 dropdown-menu dropdown-menu-end">
                      <li><a class="dropdown-item" href="#">Facebook</a></li>
                      <li><a class="dropdown-item" href="#">Instagram</a></li>
                      <li><hr class="dropdown-divider"></li>
                      <li><a class="dropdown-item" href="#">Something else here</a></li>
                    </ul>
                </div>
            </div>
        </nav>
</body>
</html>

相关问题