In my HTML, I have a certain type of box with a margin: 10px;
applied to all of them. These boxes are displayed in a row on the page using Bootstrap, and I'm trying to figure out how to remove the left margin from the first element and the right margin from the last element. The challenge is that the elements are not siblings and do not have a common parent. Here's an example of the HTML structure:
<div class='container'>
<div class='col-md-2'>
<div class='MY-CUSTOM-BOX'>
</div>
</div>
<div class='col-md-5'>
<div class='MY-CUSTOM-BOX'>
</div>
</div>
<div class='col-md-5'>
<div class='MY-CUSTOM-BOX'>
</div>
</div>
</div>
While :first-of-type
applies to all boxes, there's uncertainty about how to approach :first-child
because of the nested divs
. Any suggestions on how to tackle this issue?