Fix altezza immagini non costante in homepage

This commit is contained in:
2026-04-01 12:27:52 +02:00
parent 99a5bd74b8
commit ec04543775
2 changed files with 17 additions and 1 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ if ($result === false) {
<div class="products-grid">
<?php while ($row = $result->fetch_assoc()): ?>
<div class="product-card">
<a href="product.php?id=<?php echo $row['ProductID']; ?>"><img src="img/<?php echo htmlspecialchars($row['ImagePath']); ?>" alt="Immagine prodotto"></a>
<a href="product.php?id=<?php echo $row['ProductID']; ?>"><div class="img-square"><img src="img/<?php echo htmlspecialchars($row['ImagePath']); ?>" alt="Immagine prodotto"></div></a>
<h3><?php echo "<a href='product.php?id=" . $row['ProductID'] . "'>" . htmlspecialchars($row['ProductName']) . "</a>"; ?></h3>
<p><?php echo htmlspecialchars($row['Price']); ?>€</p>
<button>Aggiungi al carrello</button>
+16
View File
@@ -124,3 +124,19 @@ form button:hover {
margin-right: 20px;
}
}
.img-square {
position: relative;
width: 100%;
padding-top: 100%; /* crea un quadrato perfetto */
overflow: hidden;
}
.img-square img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: contain; /* o "cover" */
}