我有一个关于将元素推向右侧的问题

时间:2019-06-29 19:31:59

标签: bootstrap-4

因此,我无法将列表发送到页面右侧。我不知道发生了什么,我尝试了一堆方法来解决它,但它只是不会转到页面的一侧。

我使用ml-auto进行移动,但是没有用

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">

<nav class = "navbar navbar-expand-md navbar-light  sticky-top">
    <div class= "cointainer-fluid">
        <a class = "navbar-brand" href= "#"> <img src = "img/lostlog.jpg" id = "brand-image"></a>
        <button class= "navbar-toggler" type = "button" data-toggle = "collaspe" data-taget= "#navbarResponsive">
            <span class= "navbar-toggler-icon"></span>
        </button>
        <div class = "collaspe navbar-collapse" id = "navbarResponsive">
            <ul class ="navbar-nav ml-auto">
                <li class= "nav-item active">
                    <a class = "nav-link" href="#">Home</a>
                </li>
                <li class= "nav-item">
                    <a class = "nav-link" href="#">Home</a>
                </li>
                <li class= "nav-item">
                    <a class = "nav-link" href="#">Home</a>
                </li>
                <li class= "nav-item">
                    <a class = "nav-link" href="#">Home</a>
                </li>
            </ul>
        </div>
    </div>
</nav>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

1 个答案:

答案 0 :(得分:0)

您无法通过删除可以实现目标的方式在navbar中添加容器流体。

collaspe替换为collapse,将taget替换为target

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">

<nav class = "navbar navbar-expand-md navbar-light  sticky-top">
    <a class = "navbar-brand" href= "#"> <img src = "img/lostlog.jpg" id = "brand-image"></a>
    <button class= "navbar-toggler" type = "button" data-toggle = "collapse" data-target= "#navbarResponsive">
        <span class= "navbar-toggler-icon"></span>
    </button>
    <div class = "collapse navbar-collapse" id = "navbarResponsive">
        <ul class ="navbar-nav ml-auto">
            <li class= "nav-item active">
                <a class = "nav-link" href="#">Home</a>
            </li>
            <li class= "nav-item">
                <a class = "nav-link" href="#">Home</a>
            </li>
            <li class= "nav-item">
                <a class = "nav-link" href="#">Home</a>
            </li>
            <li class= "nav-item">
                <a class = "nav-link" href="#">Home</a>
            </li>
        </ul>
    </div>
</nav>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>