Home > Article > Web Front-end > How to Control Margins and Padding Between Columns in Bootstrap?
Managing Margins and Padding in Columns with Bootstrap
When working with Bootstrap's grid layout, it can be desirable to adjust the space between columns. This can be achieved by incorporating additional margin and padding.
One common approach is to modify the classes of the columns, using options like col-md-5 with pull-left and pull-right. However, this technique may result in excessive spacing.
An alternative solution is to create a nested div element within each col-md-6 column. The backbone of the column remains intact, while the nested div can be assigned the desired margin and padding.
Example:
HTML:
<code class="html"><div class="row"> <div class="text-center col-md-6"> <div class="classWithPad">Widget 1</div> </div> <div class="text-center col-md-6"> <div class="classWithPad">Widget 2</div> </div> </div></code>
CSS:
<code class="css">.classWithPad { margin: 10px; padding: 10px; }</code>
This approach allows for precise control over the spacing between columns, without compromising the grid layout.
The above is the detailed content of How to Control Margins and Padding Between Columns in Bootstrap?. For more information, please follow other related articles on the PHP Chinese website!