2
I’m working with bootstrap + codeigniter and I can’t align the products in the center of a div. I would like the blue items in the center to be aligned by the center.
HTML/PHP
<div class="col-md-3 col-sm-12 col-centered portfolio-item <?php echo $p->SubCategoria . " " . $p->SubCategoria2 . " " . $p->SubCategoria3 ?>">
<div class="portfolio-item-inner">
<a href="<?php echo base_url("produtos/" . $p->LinkE . "/" . $p->LinkC . "/" .$p->Link) ?>">
<div class="media-body circular" style="background: url(<?php echo $Imagem ?>) no-repeat;">
</div>
<p style="margin: 8px;" align="center"><?php echo $p->Titulo ?></p></a>
</div>
</div><!--/.portfolio-item-->
CSS
#portfolio .portfolio-items {
margin: -15px;
text-align: center;
}
#portfolio .portfolio-item {
max-width: 290px;
min-width: 290px;
//float: left;
padding: 15px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-o-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
.row-centered {
text-align:center;
}
.col-centered {
display:inline-block;
float:center;
/* reset the text-align */
text-align:left;
/* inline-block space fix */
margin-right:-4px;
}
Put the code in Jsfiddle here is cut.
– Steve Angello
but has a looping to display the products, I do not know if it will work very well.
– Davi R Rossini
Here you will find a complete guide, with the ways to center vertically, horizontally and both. https://css-tricks.com/centering-css-complete-guide/
– Skramewell