Html CSS不等分盒
我有个问题。我试图在数据库中显示一个Html CSS不等分盒,html,css,Html,Css,我有个问题。我试图在数据库中显示一个divforeach行。下面是我现在拥有的html代码: <div class="column middle"> <table> <?php $row_count = $result->num_rows; $i = 0; while($row = mysqli_fetch_assoc($result)) {
div
foreach
行。下面是我现在拥有的html代码:
<div class="column middle">
<table>
<?php
$row_count = $result->num_rows;
$i = 0;
while($row = mysqli_fetch_assoc($result))
{
if ($i == 0 or $i == 2)
{
echo "<tr>";
}
echo "<td>";
echo "<div class='list_column'>
<form method='post' action='producten.php'>
<input type='hidden' name='restaurant_id' value=".$row['id']." />
<div class='foto'><img src='".$row['picture']."' style='width: 100%; height: 25%;'/></div>
<div class='name'>".$row['name']."</div>
<button type='submit' class='order'>Bestellen</button>
</form>
</div>";
echo "</td>";
$i += 1;
if ($i == 2)
{
$i = 0;
echo "</tr>";
}
}
?>
</table>
</div>
下面是我目前的结果:
正如您所看到的,div
的大小不相等。我想要的是div
中的图像是正方形,并且list_列的div大小彼此相等,即使图像不是正方形且相等
我该怎么做呢?我认为您需要确定图像的大小(例如:250x250)。使用上面的代码,可以使用宽度:100%
设置图像样式。如果图像大小不一样,该列将喜欢您的结果图像。好吧。。。。如果有人能给我一个财产或者我能处理的东西就足够了,但现在我一无所有,我为这个问题挣扎了好几次。所以,如果你有什么css属性我需要使用的建议,这将是非常有帮助的!为什么使用表格进行布局?不要使用表格进行布局。你不再是90年代的人了!使用div准备布局并以%为单位指定宽度,以便快速修复。但不要将div嵌套在表单元格中。Afaik甚至都不应该是有效的html。我没有办法使用百分比?很难使用百分比,因为图像的大小不同。但是如果你想这样做,我建议你将图像的宽度调整到精确的像素。例如:您有4个图像和图像的大小(300、200、500、200),您可以选择最小宽度并自动调整高度。另一种方法是,可以像(400x400)一样修复绑定图像的框,图像将修复到父对象。
.column.middle {
width: 60%;
}
.list_column {
float:left;
padding: 10px;
text-align: center;
width:50%;
}
.list_column:hover {
box-shadow: 0 0 0 2px #e5e5e5;
cursor:pointer;
}
.list_column .name {
font-weight:bold;
}
.list_column .order {
text-transform: uppercase;
background: #F68B1E;
border: 1px solid #F68B1E;
cursor: pointer;
color: #fff;
padding: 8px;
margin-top: 10px;
}
.list_column .order:hover {
background: #f17e0a;
border-color: #f17e0a;
}