通过CSS内联显示图像

时间:2012-11-07 04:36:02

标签: html css wordpress position

我想要在一行中彼此相邻地显示三张图像。

这是HTML:

<div id="client_logos">
<img style="display: inline; margin: 0 5px;" title="heartica_logo" src="https://s3.amazonaws.com/rainleader/assets/heartica_logo.png" alt="" width="150" height="50" />
<img style="display: inline; margin: 0 5px;" title="mouseflow_logo" src="https://s3.amazonaws.com/rainleader/assets/mouseflow_logo.png" alt="" width="150" height="50" />
<img style="display: inline; margin: 0 5px;" title="piiholo_logo" src="https://s3.amazonaws.com/rainleader/assets/piiholo_logo.png" alt="" width="150" height="50" />
</div>

这是CSS:

#client_logos { display: inline-block; }

出于某种原因,它只显示彼此相邻的两个徽标。不确定是什么问题。有什么想法吗?

网址:http://rainleader.com/who-we-are/

查看屏幕截图。enter image description here

3 个答案:

答案 0 :(得分:14)

您的标记中的第二张和第三张图片之间有换行符<br>。摆脱它,它将显示内联。

答案 1 :(得分:5)

您在此处发布的代码和您网站上的代码都不同。第二张图片后有一个中断<br>,所以第三张图片进入新行,删除此<br>,它会正确显示。

答案 2 :(得分:3)

将此css放在您的页面中:

<style>
   #client_logos {
    display: inline-block;
    width:100%;
    }
  </style>

<强>替换

<p><img class="alignnone" style="display: inline; margin: 0 10px;" title="heartica_logo" src="https://s3.amazonaws.com/rainleader/assets/heartica_logo.png" alt="" width="150" height="50" /><img class="alignnone" style="display: inline; margin: 0 10px;" title="mouseflow_logo" src="https://s3.amazonaws.com/rainleader/assets/mouseflow_logo.png" alt="" width="150" height="50" /><img class="alignnone" style="display: inline; margin: 0 10px;" title="mouseflow_logo" src="https://s3.amazonaws.com/rainleader/assets/piiholo_logo.png" alt="" width="150" height="50" /></p>

<div id="client_logos">
<img style="display: inline; margin: 0 5px;" title="heartica_logo" src="https://s3.amazonaws.com/rainleader/assets/heartica_logo.png" alt="" width="150" height="50" />
<img style="display: inline; margin: 0 5px;" title="mouseflow_logo" src="https://s3.amazonaws.com/rainleader/assets/mouseflow_logo.png" alt="" width="150" height="50" />
<img style="display: inline; margin: 0 5px;" title="piiholo_logo" src="https://s3.amazonaws.com/rainleader/assets/piiholo_logo.png" alt="" width="150" height="50" />
</div>