douya1061 2017-02-01 09:53
浏览 81
已采纳

到达DIV容器结束后中断行

I have the following code where the images are fetched from the database. It keeps going breaking the DIV and overflows. What I want is when the images reach the end of the DIV it should break and start a new line. But I have no idea as how to achieve this. Please help me guys.

Code

<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">&times;</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;
}
  • 写回答

3条回答 默认 最新

  • doudihuang7642 2017-02-04 14:12
    关注

    I found the answer to my solution. Added an extra DIV with class .proof-container with property position: relative; and wrapped all elements inside it and added a property float: left; to .image-container. That's it. Below is the code:

    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">&times;</span> <img class="modal-content" id="modalImg">
              <div id="caption"></div>
            </div>
            <?php } ?>
          </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?