从 Bootstrap 3 中的列中删除填充 [英] Remove padding from columns in Bootstrap 3

查看:21
本文介绍了从 Bootstrap 3 中的列中删除填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

在 Bootstrap 3 中删除 col-md-* 左右两侧的填充/边距.

HTML 代码:

<h2>OntoExplorer<span style="color:#b92429">.</span></h2><div class="col-md-4"><div class="widget"><div class="widget-header"><h3>尺寸</h3>

<div class="widget-content" id=""><div id='jqxWidget'><div style="clear:both;margin-bottom:20px;"id="listBoxA"></div><div style="clear:both;"id="listBoxB"></div>

<div class="col-md-8"><div class="widget"><div class="widget-header"><h3>结果</h3>

<div class="widget-content"><div id="map_canvas" style="height: 362px;"></div>

期望的输出:

目前这段代码在两列的左右两边添加了填充/边距.我想知道我缺少什么才能去除侧面的这个额外空间?

注意:

如果我删除col-md-4",那么两列都会扩展到 100%,但我希望它们彼此相邻.

解决方案

你通常会使用 .row 来包装两列,而不是 .col-md-12 - 这是一列包含另一列.毕竟,.row 没有 col-md-12 会带来的额外边距和填充,并且还降低了列会引入负左 & 的空间.右边距.

<div class="row"><h2>OntoExplorer<span style="color:#b92429">.</span></h2><div class="col-md-4 nopadding"><div class="widget"><div class="widget-header"><h3>尺寸</h3>

<div class="widget-content">

<div class="col-md-8 nopadding"><div class="widget"><div class="widget-header"><h3>结果</h3>

<div class="widget-content">

如果您真的想要删除内边距/边距,请添加一个类来过滤掉每个子列的边距/内边距.

.nopadding {填充:0!重要;边距:0 !重要;}

Problem:

Remove padding/margin to the right and left of col-md-* in Bootstrap 3.

HTML code:

<div class="col-md-12">
    <h2>OntoExplorer<span style="color:#b92429">.</span></h2>

    <div class="col-md-4">
        <div class="widget">
            <div class="widget-header">
                <h3>Dimensions</h3>
            </div>

            <div class="widget-content" id="">
                <div id='jqxWidget'>
                    <div style="clear:both;margin-bottom:20px;" id="listBoxA"></div>
                    <div style="clear:both;" id="listBoxB"></div>

                </div>
            </div>
        </div>
    </div>

    <div class="col-md-8">
        <div class="widget">
            <div class="widget-header">
                <h3>Results</h3>
            </div>

            <div class="widget-content">
                <div id="map_canvas" style="height: 362px;"></div>
            </div>
        </div>
    </div>

</div>

Desired output:

Currently this code adds padding/margin to the right and left of the two columns. I am wondering what it is I am missing in order to remove this extra space on the sides?

Notice:

If I remove "col-md-4" then both columns expand to 100% but I want them to be next to each other.

解决方案

You'd normally use .row to wrap two columns, not .col-md-12 - that's a column encasing another column. Afterall, .row doesn't have the extra margins and padding that a col-md-12 would bring and also discounts the space that a column would introduce with negative left & right margins.

<div class="container">
    <div class="row">
        <h2>OntoExplorer<span style="color:#b92429">.</span></h2>

        <div class="col-md-4 nopadding">
            <div class="widget">
                <div class="widget-header">
                    <h3>Dimensions</h3>
                </div>
                <div class="widget-content">
                </div>
            </div>
        </div>

        <div class="col-md-8 nopadding">
            <div class="widget">
                <div class="widget-header">
                    <h3>Results</h3>
                </div>
                <div class="widget-content">
                </div>
            </div>
        </div>
    </div>
</div>

if you really wanted to remove the padding/margins, add a class to filter out the margins/paddings for each child column.

.nopadding {
   padding: 0 !important;
   margin: 0 !important;
}

这篇关于从 Bootstrap 3 中的列中删除填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆