下面是从数据库中获取图像的代码。它一直在破坏DIV和overflows。我想要的是当图像到达DIV的末尾时,它应该中断并开始一条新的行。但我不知道如何做到这一点。请帮帮我伙计们。
代码
<div class="inline-flex">
<?php while($faf = $prooq->fetch()){ extract($faf); ?>
<div class="image-container"> <img class="myThumb" id="myImg" src="proofs/<?php echo $pr_image; ?>" alt="" width="160" height="100">
<div class="image-text">shreyansh ($8.75)<br>
<span><?php echo date('jS M, Y (h:i a)', strtotime($pr_uptime)); ?></span></div>
</div>
<div id="myModal" class="modal"> <span class="close">×</span> <img class="modal-content" id="modalImg">
<div id="caption"></div>
</div>
<?php } ?>
</div>CSS
.image-container {
width: 163px;
height: 100px;
padding: 0px 0px 65px 0px;
font-size: 12px;
text-align: center;
font-family: Verdana, Arial, Helvetica, sans-serif;
margin-right: 13px;
}
.image-text {
margin-top: 5px;
}
.image-text span {
color: #ddd;
font-size: 9px;
}
.inline-flex {
width: 100%;
display: inline-flex;
}发布于 2017-02-04 14:12:53
我找到了解决方案的答案。在带有属性.proof-container的类position: relative;中添加了一个额外的DIV,并封装了其中的所有元素,并向.image-container添加了一个属性float: left;。就这样。以下是代码:
CSS:
.image-container {
width: 197px;
height: 120px;
padding: 0px 0px 65px 0px;
font-size: 12px;
text-align: center;
font-family: Verdana, Arial, Helvetica, sans-serif;
margin-right: 10px;
float: left;
}
.proof-container {
width: 100%;
position: relative;
}HTML:
<div class="proof-container">
<?php while($faf = $prooq->fetch()){ extract($faf); ?>
<div class="image-container">
<img class="myThumb" id="myImg" src="proofs/<?php echo $pr_image; ?>" alt="" width="160" height="100">
<div class="image-text"><?php echo $mem_uname; ?> ($8.75)<br>
<span><?php echo date('jS M, Y (h:i a)', strtotime($pr_uptime)); ?></span></div>
</div>
<div id="myModal" class="modal"> <span class="close">×</span> <img class="modal-content" id="modalImg">
<div id="caption"></div>
</div>
<?php } ?>
</div>发布于 2017-02-01 10:33:20
尝试使用display:table
.inline-flex {
width: 100%;
display: table;
}发布于 2017-02-01 11:13:18
您需要将display: inline-block; float: left;设置为.image-container
.image-container {
width: 163px;
height: 120px;
padding: 0px 0px 65px 0px;
font-size: 12px;
text-align: center;
font-family: Verdana, Arial, Helvetica, sans-serif;
margin-right: 13px;
display: inline-block;
float: left;
}
.image-text {
margin-top: 5px;
}
.image-text span {
color: #ddd;
font-size: 9px;
}
.inline-flex {
width: 100%;
}<div class="inline-flex">
<div class="image-container"> <img class="myThumb" id="myImg" src="http://lorempixel.com/output/nature-q-c-200-200-3.jpg" alt="" width="160" height="100">
<div class="image-text">shreyansh ($8.75)<br>
<span>date('jS M, Y (h:i a)', strtotime($pr_uptime));</span></div>
</div>
</div>
<div class="image-container"> <img class="myThumb" id="myImg" src="http://lorempixel.com/output/nature-q-c-200-200-3.jpg" alt="" width="160" height="100">
<div class="image-text">shreyansh ($8.75)<br>
<span>date('jS M, Y (h:i a)', strtotime($pr_uptime));</span></div>
</div>
<div class="image-container"> <img class="myThumb" id="myImg" src="http://lorempixel.com/output/nature-q-c-200-200-3.jpg" alt="" width="160" height="100">
<div class="image-text">shreyansh ($8.75)<br>
<span>date('jS M, Y (h:i a)', strtotime($pr_uptime));</span></div>
</div>
<div class="image-container"> <img class="myThumb" id="myImg" src="http://lorempixel.com/output/nature-q-c-200-200-3.jpg" alt="" width="160" height="100">
<div class="image-text">shreyansh ($8.75)<br>
<span>date('jS M, Y (h:i a)', strtotime($pr_uptime));</span></div>
</div>
<div class="image-container"> <img class="myThumb" id="myImg" src="http://lorempixel.com/output/nature-q-c-200-200-3.jpg" alt="" width="160" height="100">
<div class="image-text">shreyansh ($8.75)<br>
<span>date('jS M, Y (h:i a)', strtotime($pr_uptime));</span></div>
</div>
<div class="image-container"> <img class="myThumb" id="myImg" src="http://lorempixel.com/output/nature-q-c-200-200-3.jpg" alt="" width="160" height="100">
<div class="image-text">shreyansh ($8.75)<br>
<span>date('jS M, Y (h:i a)', strtotime($pr_uptime));</span></div>
</div>
https://stackoverflow.com/questions/41976637
复制相似问题