While working with Bootstrap 5 and using paddings in columns, I encountered issues when some of my columns had backgrounds or when adding an embed element. How can I create margins in such cases?
https://i.sstatic.net/EhF7y.png
To address this issue, I implemented a workaround by assigning different classes to my three gray blocks and applying left and right margins as needed for each.
I initially wanted to structure it like this:
<div class="row">
<div class="col-12">
My blue section
</div>
</div>
<div class="row">
<div class="col-4">
Grey section 1
</div>
<div class="col-4">
Grey section 2
</div>
<div class="col-4">
Grey section 3
</div>
</div>
However, I realized that I would not have margins between my gray items using this approach. So, I tried encapsulating each gray item like this:
<div class="row">
<div class="col-4">
<div class="item">
Grey section 1
</div>
</div>
<div class="col-4">
<div class="item">
Grey section 2
</div>
</div>
<div class="col-4">
<div class="item">
Grey section 3
</div>
</div>
</div>
However, this solution also presented challenges as the margins from the row affected the overall width difference between the gray sections and the blue section.
I faced similar issues with videos: if I don't wrap the video in a child div, there are no margins causing alignment problems.
Any suggestions on how to address these issues effectively?