如何使< img>标签水平地排列在div? [英] How to make the <img> tags line up horizontally in the div?

查看:138
本文介绍了如何使< img>标签水平地排列在div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使图像在div中水平并排显示。



HTML

 < div class =Wrapper> 
< img src =/ wp-content / uploads / 2012/07 / TFT.pngalt =Smiley faceheight =90width =95/>
< img src =/ wp-content / uploads / 2012/07 / Ltyt.pngalt =Smiley faceheight =90width =95/>
< img src =/ wp-content / uploads / 2012/07 / artspngalt =Smiley faceheight =90width =95/>
< / div>

参考: jsFiddle

解决方案

您也可以使用css属性 display :inline-block float:left 来实现。



HTML代码

 < div> 
< img ... />
< img ... />
< img ... />
< / div>

CSS代码

  div img {display:inline-block;} 

  div img {display:block; float:left; margin-right:5px;} 
pre>

I need to make the images show up side by side horizontally in the div. How can I do that?

HTML:

<div class="Wrapper">
  <img src="/wp-content/uploads/2012/07/TFT.png" alt="Smiley face" height="90" width="95" />
  <img src="/wp-content/uploads/2012/07/Ltyt.png" alt="Smiley face" height="90" width="95" />
  <img src="/wp-content/uploads/2012/07/artspng" alt="Smiley face" height="90" width="95" />
</div>

Reference: jsFiddle

解决方案

You could also use css properties display:inline-block or float : left to achieve this.

HTML Code

<div>
    <img ... />
    <img ... />
    <img ... />
</div>

CSS Code

div img{ display: inline-block;}

or

div img{ display: block;float: left;margin-right: 5px;}

这篇关于如何使&lt; img&gt;标签水平地排列在div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆