dtbrd80422 2013-07-24 20:08
浏览 31
已采纳

php搜索结果图像显示并填充CSS div

I'm using dreamweaver and php to return a list of images based on search critiera. I have used Dreamweaver's repeat function and can get the images to repeat below each other (as below).

<table width="100" height="38" border="1"> 
<?php do { ?> 
<tr> 
<td width="38">
<img class='example' src="images/<?php echo $row_getresult['image_name']; ?>.png"/><br>       
</a></td></tr> 
<?php } while ($row_getamenityaccommodation = mysql_fetch_assoc($getamenityaccommodation)); 
?> 
</table>

How can I get the images to go across from each other within a CSS Div e.g. float:left; width:45%; so that if there are more images than what would fit in 45%, the images would continue onto a new line?

Would somehow 'printing' the array work?

  • 写回答

1条回答 默认 最新

  • dorv56831 2013-07-24 20:20
    关注

    Remove the table and replace with

    <div style='width:45%'>
    <?php do{ ?>
    <img style='float:left;class='example' src="images/<?php echo $row_getresult['image_name']; ?>.png"/>
    <?php } while ($row_getamenityaccommodation = mysql_fetch_assoc($getamenityaccommodation)); ?>
    </div>
    

    or for a more semantic version use a ul since you are showing a list of images.

    <ul class='gallery'>
    <?php do{ ?>
    <li><img style='float:left;class='example' src="images/<?php echo $row_getresult['image_name']; ?>.png"/></li>
    <?php } while ($row_getamenityaccommodation = mysql_fetch_assoc($getamenityaccommodation)); ?>
     </ul>
    

    and in css

      ul.gallery {
           width: 45%;
           list-style: none;
           margin:0; padding:0;
      }
    
      ul.gallery li {
           float:left;
           padding: 5px;
      }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记