Problem with Dropdown in bootstrap Navigation bar

Viewed 31

screenshotI want the dropdown menu not to overlap with other items in navigation bar. How to offset dropdown items below the navigation bar.

        <!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>
1 Answers

Try adding mt-3 class to the ul tag:

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

Related