我有以下CSS,它使图像在到达DIV结束后中断行,但它后面的DIV容器根据图像没有占据高度。高度应随图像一起扩展。这是屏幕截图http://prnt.sc/e3fqvr。
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;
display: inline-block;
float: left;
}
.proof-container {
width: 100%;
position: absolute;
}
.container {
width: 100%;
min-height: 500px;
}
.container-inside {
border: 1px solid #1df2f2;
width: 100%;
border-radius: 5px;
margin-top: 10px;
padding: 20px;
box-sizing: border-box;
}
HTML:
<div class="container">
<div class="container-inside">
<div class="container-title">Images</div>
<br>
<div class="proof-container">
<?php while($faf = $prooq->fetch()){ extract($faf); ?>
<div class="image-container"> <img class="myThumb" id="myImg" src="https://wallpaperstock.net/wallpapers/thumbs1/45957hd.jpg" 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>
</div>
</div>
请帮助我开发。
答案 0 :(得分:3)
尝试删除css属性
_backend_2_
并添加
position:absolute from proof-container
答案 1 :(得分:0)
您可以将.container-inside
提供给float:left
。如果你不想浮动。然后只需将clearfix
类赋予.container-inside
并添加clearfix属性。
<强> float Fiddle Demo 强>
<强> clearfix fiddle demo 强>
,如果不需要,请从.proof-container
删除绝对值。
并制作model
display:none
,因为您想要点击图片来展示模特。制作模型position:absolute
并根据需要进行调整。
<强> This fiddle 强>
答案 2 :(得分:0)
将overflow: hidden;
或overflow: auto
添加到.container-inside
,然后从position: absolute
.proof-container
.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;
display: inline-block;
float: left;
}
.proof-container {
width: 100%;
}
.container {
width: 100%;
min-height: 500px;
}
.container-inside {
border: 1px solid #1df2f2;
width: 100%;
border-radius: 5px;
margin-top: 10px;
padding: 20px;
box-sizing: border-box;
overflow: hidden;
}
&#13;
<div class="container">
<div class="container-inside">
<div class="container-title">Images</div>
<br>
<div class="proof-container">
<div class="image-container">
<img class="myThumb" id="myImg" src="https://wallpaperstock.net/wallpapers/thumbs1/45957hd.jpg" alt="" width="160" height="100">
<div class="image-text">shreyansh ($8.75)
<br>
</div>
</div>
<div id="myModal" class="modal"> <span class="close">×</span>
<img class="modal-content" id="modalImg">
<div id="caption"></div>
</div>
</div>
</div>
</div>
&#13;
答案 3 :(得分:0)
添加溢出:自动到.container-inside
并移除位置:绝对从.proof-container
添加样式到您的模态,如下所示。
.image-container {
width: 163px;
height: 100px;
font-size: 12px;
text-align: center;
font-family: Verdana, Arial, Helvetica, sans-serif;
display: inline-block;
padding: 0px 0px 65px 0px;
float:left;
}
.proof-container {
width: 100%;
}
.container {
width: 100%;
min-height: 500px;
}
.container-inside {
border: 1px solid #1df2f2;
width: 100%;
border-radius: 5px;
margin-top: 10px;
padding: 20px;
box-sizing: border-box;
overflow:auto;
}
#myModal{
float:left;
margin-right: 10px;
}
<div class="container">
<div class="container-inside">
<div class="container-title">Images</div>
<br>
<div class="proof-container">
<div class="image-container"> <img class="myThumb" id="myImg" src="https://wallpaperstock.net/wallpapers/thumbs1/45957hd.jpg" alt="" width="160" height="100">
<div class="image-text">shreyansh ($8.75)<br>
<span>2nd Feb, 2017 (01:02 pm)</span></div>
</div>
<div id="myModal" class="modal"> <span class="close">×</span> <img class="modal-content" id="modalImg">
<div id="caption"></div>
</div>
<div class="image-container"> <img class="myThumb" id="myImg" src="https://wallpaperstock.net/wallpapers/thumbs1/45957hd.jpg" alt="" width="160" height="100">
<div class="image-text">shreyansh ($8.75)<br>
<span>2nd Feb, 2017 (01:02 pm)</span></div>
</div>
<div id="myModal" class="modal"> <span class="close">×</span> <img class="modal-content" id="modalImg">
<div id="caption"></div>
</div>
<div class="image-container"> <img class="myThumb" id="myImg" src="https://wallpaperstock.net/wallpapers/thumbs1/45957hd.jpg" alt="" width="160" height="100">
<div class="image-text">shreyansh ($8.75)<br>
<span>2nd Feb, 2017 (01:02 pm)</span></div>
</div>
<div id="myModal" class="modal"> <span class="close">×</span> <img class="modal-content" id="modalImg">
<div id="caption"></div>
</div>
<div class="image-container"> <img class="myThumb" id="myImg" src="https://wallpaperstock.net/wallpapers/thumbs1/45957hd.jpg" alt="" width="160" height="100">
<div class="image-text">shreyansh ($8.75)<br>
<span>2nd Feb, 2017 (01:02 pm)</span></div>
</div>
<div id="myModal" class="modal"> <span class="close">×</span> <img class="modal-content" id="modalImg">
<div id="caption"></div>
</div>
</div>
</div>
</div>