Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
426 views
in Technique[技术] by (71.8m points)

css - 从Bootstrap 3中的列中删除填充(Remove padding from columns in Bootstrap 3)

Problem:

(问题:)

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

(删除Bootstrap 3中col-md- *右侧和左侧的填充/边距。)

HTML code:

(HTML代码:)

<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.

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

  ask by kexxcream translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You'd normally use .row to wrap two columns, not .col-md-12 - that's a column encasing another column.

(您通常使用.row来包装两列,而不是.col-md-12 - 这是一个包含另一列的列。)

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.

(毕竟, .row没有col-md-12带来的额外边距和填充,并且.row列将带有负左右边距的空间。)

<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;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...