The BootStrap grid system can divide our container into several equal parts. If we want to leave a certain amount of space between each part, the first method we may think of is to use [See an example]: CSS style: .row div { height: 100px; } HTML code: <div class="container"> <!-- Row element --> <div class="row"> <!-- Column element col-xs-value col-sm-value col-md-value col-lg-value --> <div class="col-lg-5" style="background-color: wheat;"></div> <div class="col-lg-4" style="background-color: pink;"></div> <div class="col-lg-3" style="background-color: black;"></div> </div> </div> [The original effect is as follows]:Now we want to create a gap between these three parts (10px), but we cannot change the original layout. Here we add a margin value: The css style is changed to: .row div { height: 100px; margin-right:10px; } 【Effect after adding margin value】: It was observed that one part was squeezed down, which means that this wave of operations changed the original grid layout. The reasons are as follows: When we divide the grid, each part is full and squeezed together. To create a blank space between each column, you add a Through the above operations and explanations, we know that it is not possible to achieve the effect of leaving gaps in the grid system by setting 【Solution】: We can set a CSS style: .row div { padding-left: 0px; // remove the default left padding padding-right: 10px; height: 100px; } .hezi { width: 100%; background-color: green; } HTML code: <div class="container"> <!-- Row element --> <div class="row"> <!-- Part 1 --> <div class="col-md-5" style="background-color: ;"> <div class="hezi"></div> </div> <!-- Part 2 --> <div class="col-md-4" style="background-color: ;"> <div class="hezi"></div> </div> <!-- Part 3 --> <div class="col-md-3" style="background-color: ;"> <div class="hezi"></div> </div> </div> </div> Note: BootStrap's grid system is very convenient for responsive web development. When using the grid system, you can easily use row and col to control the layout. However, col- - The final effect and analysis are as follows: SummarizeThis is the end of this article about the solution to leaving gaps between BootStrap grids. For more information about leaving gaps between BootStrap grids, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of mysql MGR single-master and multi-master mode switching knowledge points
This article mainly introduces the analysis of th...
1: Understand the meaning of address rewriting an...
Demand scenario: The boss asked me to use the cra...
Data migration needs to be imported from MySQL to...
This article shares a draggable login box impleme...
To export MySQL query results to csv , you usuall...
In the past, float was often used for layout, but...
Table of contents 1. React Hooks vs. Pure Functio...
Table of contents Backend: Rails API part Front-e...
Table of contents Process Communication Bidirecti...
Table of contents Preface 1. Custom focus command...
Reflections on the two viewpoints of “people-orie...
3. MySQL Data Management The first method: not re...
Table of contents 1. Swap partition SWAP 1.1 Crea...
1. Command Introduction The seq (Sequence) comman...