简体   繁体   English

Bootstrap 4列对齐问题

[英]Bootstrap 4 columns align issue

I'm working on making a site, and im currently dealing with BS4.1.3 I'm still new to this world so i have this issue right now: 我正在制作一个网站,目前我正在处理BS4.1.3,我对这个世界还是个陌生人,所以我现在遇到这个问题:

        <div class="container">
        <nav class="navbar sticky-top">
            <div class="grid">
                <div class="row">
                    <div class="col-md-4">
                        <a class="btn btn-primary" data-toggle="collapse" href="#collapse-top-menu" role="button" aria-expanded="false" aria-controls="collapse-top-menu">
                            <img src="img/baseline-menu-24px.svg">
                        </a>
                    </div>
                    <div class="col-md-4">
                        <a class="navbar-brand" href="#">
                            <img src="img/bootstrap-solid.svg" width="40" height="40">
                        </a>
                    </div>
                    <div class="col-md-4">
                        Test
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="collapse" id="collapse-top-menu">
                            <input type="text" class="form-control" id="input-top-collapse-search" placeholder="Cosa stai cercando?">
                        </div>
                    </div>
                </div>
            </div>
        </nav>
    </div>

But the end result it's like this 但是最终结果是这样的 在此处输入图片说明

While i wanted that the first blue button and the "logo" (B) were aligned, "test" a lot more in the right part of the navbar Also the bottom search bar should be the same width as the container, so full lenght 当我希望第一个蓝色按钮和“徽标”(B)对齐时,在导航栏的右侧进行更多的“测试”。此外,底部的搜索栏应与容器的宽度相同,因此应尽可能长

I am on mobile Stack Overflow app hence not able to test this. 我正在使用移动Stack Overflow应用程序,因此无法对此进行测试。 In Bootstap 4, to put the test at the right of the navbar you can try, 在Bootstap 4中,要将测试放在导航栏的右侧,您可以尝试,

<ul class="navbar-nav ml-auto">The content which goes to right comes here as a li</ul>

Also for aligning the blue button (The button you are using here is called as hamburger , remember that) can be aligned by using some margin-top for it. 同样,为了对齐蓝色按钮(您在此使用的按钮称为hamburger ,请记住),可以通过使用一些顶部空白来对齐它。

Just use a CSS selector to select the hamburger and give some margin-top property to it. 只需使用CSS选择器选择汉堡包,然后为其提供一些margin-top属性。

Please consider adding a codepen so that we mobile users can play around with your code. 请考虑添加一个代码笔,以便我们的移动用户可以使用您的代码。

  <div class="container">
        <nav class="navbar sticky-top">
            <div class="grid">
                <div class="row">
                    <div class="col-md-4">
                        <a class="btn btn-primary" data-toggle="collapse" href="#collapse-top-menu" role="button" aria-expanded="false" aria-controls="collapse-top-menu">
                            <img src="img/baseline-menu-24px.svg">
                        </a>
                    </div>
                    <div class="col-md-8 pull-right">
                        <a class="navbar-brand" href="#">
                            <img src="img/bootstrap-solid.svg" width="40" height="40">
                            <span>Test</span>
                         </a>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="collapse" id="collapse-top-menu">
                            <input type="text" class="form-control" id="input-top-collapse-search" placeholder="Cosa stai cercando?">
                        </div>
                    </div>
                </div>
            </div>
        </nav>
    </div>

.collapse input{
  width:100%;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM