<div class="box">
<img src="http://s21.postimg.org/c5lw89577/Untitled_2.jpg" />
<img src="http://s21.postimg.org/c5lw89577/Untitled_2.jpg" />
<p>
uspendisse potenti. Ut id justo libero, in bibes
</p>
</div>
Run Code Online (Sandbox Code Playgroud)
如何使图像src对齐到中心.我想得到的结果是喜欢下面的图片.理想情况下也适用于IE7和IE8

Ric*_*uen 10
HTML <img>元素是内联级元素,因此它们受text-align属性的影响.
段落是块级元素,因此它们不会环绕图像,除非您使用CSS来更改它.所有你需要的是:(http://jsfiddle.net/7sKeA/)
.box {
width:600px;
text-align:center;
}
img {
margin:5px;
}
Run Code Online (Sandbox Code Playgroud)
如果你还需要.box保持居中,那就用它来定位margin:auto;:(http://jsfiddle.net/7sKeA/1/)
.box {
width:600px;
text-align:center; /* center align the text inside the box */
margin:auto; /* center this .box element, assuming it is block-level */
}
img {
margin:5px;
}
Run Code Online (Sandbox Code Playgroud)