Align divs using bootstrap

1

<?php
	include "header.php";

		require 'conexion.php';
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
	
	<meta name="decription" content="etiquetas html5">
	
	
</head>

	<div class="shoes-grid">
		<div class="products">
			<h5 class="latest-product">Listado de Productos</h5>
		</div>
		<div class="product-left">
			
<?php

	$link = mysqli_connect ('localhost', 'root', '', 'catalogo');
	$sql = 'SELECT p.idProducto, p.prdNombre, p.prdPrecio, m.mkNombre, c.catNombre, p.prdPresentacion, p.prdStock, p.prdImagen
            FROM productos AS p
            INNER JOIN marcas AS m
            ON m.idMarca = p.idMarca
            INNER JOIN categorias AS c

            ON c.idCategoria = p.idCategoria
            ORDER BY idProducto';
    $resultado = mysqli_query($link, $sql) or die( mysqli_error($link) );
    mysqli_close($link);

    while ( $fila = mysqli_fetch_array( $resultado ) ){

?>
<div class="col-sm-4 col-md-4 chain-grid">
				<a href="?page=producto"><img src="images/productos/<?php echo $fila['prdImagen']; ?>" class="img-responsive"></a>
				 <div class="grid-chain-bottom">
				 <h6><a href="#"><?php echo $fila['prdNombre']; ?></a></h6>
				
					<h6><a href="?page=producto">Presentacion:<?php echo $fila['prdPresentacion'];  ?></a></h6>
					<div class="star-price">
						<div class="dolor-grid"> 
							<span class="actual">Precio:<?php echo $fila['prdPrecio'];  ?></span>
							<br>
							<span class="actual">Stock:<?php echo $fila['prdStock'];  ?> </span>
						</div> 
						<a class="now-get get-cart" href="?page=producto">VER MÁS</a> 
						<div class="clearfix"></div>
					</div>
				</div>
			</div>
			<?php
}
?>
			
			<div class="clearfix"></div> 
		  </div>
		<div class="clearfix"> </div>
	
	</div> 
	</html>
	<div class="col-md-8"> 
   
	<?php include "footer.php"; ?>

* the code I have shows the divs correctly, (with all the information in the database) but the position is the problem, it only shows two divs in a row, and leaves an empty space on the right side, then on the other row the same always showing only two divs to finish, I'm using bootstrap for the structure, but I do not know if I could fix it like this or just with a CSS sheet

    
asked by ale 23.01.2018 в 16:40
source

1 answer

1

As there is PHP and MYSQLi code, we will not be able to verify in the snippet if it works or not.

I recommend you use:

<div class="container">
<div class="row">

To contain what would be the "content"

In your code you do not have the closing of <div class="col-md-8">

Here you are dividing the content into 2: column 4 and column 8.

If you want 3 divs, you have to divide 12 (the total defined by bootstrap width:100%; in 3).

That is, three col-md-4.

Posible Solución : (If there is space left)

You can use offset provided by Bootstrap Grid System

  

Move the columns to the right using the classes .offset-md- *. These classes increase the left margin of a column by * columns. For example, .offset-md-4 moves .col-md-4 in four columns.

.offset-md-4

Read the file from Bootstrap Grid System .

    
answered by 23.01.2018 в 16:51