duanbu1421 2014-06-28 20:35
浏览 177
已采纳

br标签在动态创建的html里面不起作用[关闭]

I have some dynamic html and wants a new line, i.e. <br> tag after each <img> tag.

for ($i=1; $i < mysqli_num_rows($result_p); $i++){
$row_p = mysqli_fetch_array($result_p);
echo "<img id='". $i . "' src='". $row_p['url'] ."' width='200' height='200' alt='img'>";
echo "<br>";  // doesn't work
}

I checked the resulting html markup on W3C validation service - there is no error, but <br> tag still doesn't work.

  • 写回答

1条回答 默认 最新

  • dptiq46022 2014-06-28 20:40
    关注

    There are a lot of better solutions in order to have what you want:

    Option 1:
    Put the images list in an unorderlist putting a display:block attribute to li tags

    <ul class="images">
      <li> 
        <img src=""/>
      </li>
     </ul>
    

    Then in your css stylesheet:

    ul.images li{display:block}
    

    Option 2:
    Just surround you img tag with a block element : <div>, <p> for example and use css for giving it more space between images

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大