In this particular scenario, I am looking to dynamically add columns in a row. The row can contain zero, one, or a maximum of four col-sm-3 columns. Regardless of how many columns are present, the content should always be centered.
<div class="row">
<div class="col col-sm-3 col-xs-6">
<div class="servicesContent">
<img src="a.jpg" class="img-responsive" />
<p class="servicesContentTitle">lorem ipsum</p>
</div>
</div>
</div>
To achieve this layout, the following CSS code has been implemented:
.row{
text-align:center;
}
.col{
float:none;
display:inline-block;
}
Although this setup works well with three columns, it encounters issues when there are four col-sm-3 columns, resulting in misalignment as shown below:
https://i.sstatic.net/NuGmS.png
What would be the correct CSS solution to ensure perfect center alignment for any number of columns within the row?