我在我的网页上并排显示2张图片。我试图在两个图像之间保留一个空间,但我无法做到这一点。我使用css来同时显示图像。
以下是我的Html代码:
<div id="divCenter">
<img src="Company Logo.jpg" alt="Company Logo" style="width:150px;height:150px" id="divIDOne"/>
<%-- Code for the motion image --%>
<object type="application/x-shockwave-flash" data="animation.swf" width="719" height="174" id="divIDTwo">
<param name="movie" value="animation.swf" />
</object>
</div>下面是我的css代码:
#divCenter {
text-align: center;
}
#divIDOne {
margin-right: 200px;
}
#divIDTwo {
margin-left: 300px;
}下面是它显示的内容:

问你可以看到,没有空间之间的2张图片。我该如何解决这个问题?
谢谢您抽时间见我
发布于 2014-09-12 05:36:59
而不是text-align:center;,使用margin:0px auto;并指定宽度和高度属性。尝尝这个。HTML
<div id="divCenter">
<img src="#" alt="Company Logo" style="width:150px;height:150px" id="divIDOne"/>
<!-- <%-- Code for the motion image --%> -->
<object type="application/x-shockwave-flash" data="animation.swf" width="780" height="174" id="divIDTwo">
<param name="movie" value="animation.swf" />
</object>
</div>CSS
#divCenter {
margin:0px auto;
width:960px;
height:auto;
padding:10px;
}
#divIDOne {
margin-right: 0px;
}
#divIDTwo {
margin-left: 20px;
}发布于 2014-09-12 05:10:48
您可以使用padding或margin来获取两个图像之间的空间。
#divCenter {
text-align: center;
}
#divCenter image {
padding:2px;
margin:2px;
}但是更好的方法是将图像保存在像li、div或td这样的容器中。
发布于 2014-09-12 05:19:17
您可以将display属性设置为内联值,即display=inline,如果需要,您可以为图像留出一些空间,这将在它们之间增加空间。更准确地说,您可以将右图像的margin-left属性设置为所需的值,或者将左图像的margin-right属性设置为所需的值,以在它们之间添加空间。
https://stackoverflow.com/questions/25801146
复制相似问题