简体   繁体   English

Bootstrap导航栏和左填充

[英]Bootstrap navbar and left padding

I have this navbar I have created to filter a datatable. 我已创建此导航栏来过滤数据表。 The html looks like this: html看起来像这样:

<div class="navbar navbar-default" role="navigation">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#datatable-navbar"></button>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="datatable-navbar">                                        
        <form class="navbar-form navbar-left" role="form">                                              
            <button type="button" class="btn btn-default">Delete</button>

            <div class="form-group">
                <select class="form-control">
                    <option selected>All categories</option>
                    <option>Category one</option>
                    <option>Category two</option>
                    <option>Category three</option>
                </select>
            </div>

            <div class="form-group">
                <select class="form-control">
                    <option selected>All articles</option>
                    <option>Article one</option>
                    <option>Article two</option>
                    <option>Article three</option>
                </select>
            </div>

            <button type="submit" class="btn btn-default">Filter</button>
        </form>

        <form class="navbar-form navbar-right" role="form">                                                                   
            <div class="form-group">
                <label>Views</label>
                <select class="form-control">
                    <option selected>All</option>
                    <option>5</option>
                    <option>10</option>
                    <option>15</option>
                </select>
            </div>

            <div class="form-group">
                <label>Posts</label>
                <div class="btn-group">
                    <button type="button" class="btn btn-default">Left</button>
                    <button type="button" class="btn btn-default">Right</button>
                </div>
            </div>

        </form>
    </div><!-- /.navbar-collapse -->
</div>

Nothing is untoward, but for some reason the padding on the .navbar-form gives the navbar a double padding. 没有什么不好的,但是由于某些原因,.navbar形式的填充为导航栏提供了双重填充。 The padding used is 0px 15px 0px 15px which is the default (unchanged) 使用的填充为0px 15px 0px 15px ,这是默认值(未更改)

Here is a fiddle for you to see. 这是一个小提琴供您查看。

http://jsfiddle.net/4Kt9Y/1/ http://jsfiddle.net/4Kt9Y/1/

If I override .navbar-form to use 0px 15px 0px 0px do you think this will cause any problems? 如果我覆盖.navbar-form以使用0px 15px 0px 0px ,您认为这会引起任何问题吗?

just add this line in your code it wont cause any problem. 只需在您的代码中添加此行,就不会引起任何问题。 If you are changing the breakpoint then do update inthe media queries 如果要更改断点,请在媒体查询中进行更新

@media (min-width:0px;) and (max-width: 767px) {
   .navbar-collapse {
        padding-left: 15px;
   }
}

@media (min-width: 768px) {
 .navbar-collapse {
        padding-left: 0;
   }
}

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

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