Home > Web Front-end > CSS Tutorial > How to Add Spacing Between Columns in Bootstrap Grid Layout?

How to Add Spacing Between Columns in Bootstrap Grid Layout?

Patricia Arquette
Release: 2024-11-04 18:15:02
Original
560 people have browsed it

How to Add Spacing Between Columns in Bootstrap Grid Layout?

Spacing Columns in Bootstrap Grid Layout

Adding margin or padding to create space between columns in Bootstrap can be tricky. To achieve this without affecting column alignment, follow these steps:

Create an Inner Div Within the Column

Create a div within the col-md-6 element and apply the desired margin and padding to it. This div will act as the spine of the column while providing the necessary spacing.

<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>
Copy after login

Add Custom Styling

In your CSS, apply the desired margin and padding to the inner div.

<code class="css">.classWithPad {
    margin: 10px;
    padding: 10px;
}</code>
Copy after login

This approach allows you to easily adjust the spacing between columns without compromising the integrity of the Bootstrap grid layout.

The above is the detailed content of How to Add Spacing Between Columns in Bootstrap Grid Layout?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template