使用 bootstrap5 使导航栏开始/结束边距左右接近边缘

问题描述 投票:0回答:1

如果我删除 ms-2,它会向右移动,放回去,它会向左移动。 我尝试了各种选择,但我似乎无法理解它是如何工作的,以及需要遵循的顺序。我现在发现引导程序在我的大脑中很复杂......

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap demo</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
  </head>
  <body>
    <h1>Hello, world!</h1>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
  </body>
</html>



<!-- navbar -->
<nav class="navbar navbar-expand bg-dark navbar-dark py-0  scroll">
    <div class="container ps-2 pe-2 ms-2 me-2">
        <a href="/" style="color: #9a9d9e">
            <img alt="tz" src="{% static 'main/img/favicon.ico' %}"
            width="33" height="33" class="navbar-brand">
            TestEEzEE
         </a>

        <button 
            class="navbar-toggler" 
            type="button" 
            data-bs-toggle="collapse" 
            data-bs-target="#navmenu"
        >
            <span class="navbar-toggler-icon"></span>
       </button>


      <div class="collapse navbar-collapse" id="navmenu">
            <ul class="navbar-nav ms-auto">
                <li class="nav-item">
                    <a href="#More" class="nav-link">More</a>
                </li>
            </ul>
        </div>
    </div>
</nav>

html bootstrap-5 navbar
1个回答
0
投票

同时拥有

ms-2
me-2
对我有用,但如果它不适合你,请尝试
mx-2
(这意味着只有水平边距 2)

© www.soinside.com 2019 - 2024. All rights reserved.