以html为中心将图像彼此相邻

时间:2014-07-12 14:04:36

标签: html css image alignment center

我有3张图片,我想让所有图像在我的水平线之后成为页面的中心

这是代码

<div class="footer">
    <hr>
    <p id="socmed">Connect Socially With Us:</p>
    <img id="fb" border="0" src="image/fb.png" alt="Facebook Fan Page" align="center">
    <img id="twitter" border="0" src="image/twitter.png" alt="Facebook Fan Page" align="center">
    <img id="youtube" border="0" src="image/youtube.png" alt="Facebook Fan Page" align="center">
    <hr>
</div>

hr{
    border: 0;
    height: 5px;
    background-image: -webkit-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0)); 
    background-image:    -moz-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0)); 
    background-image:     -ms-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0)); 
    background-image:      -o-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0)); 
}

我正在尝试使用对齐功能,但它没有产生任何效果

有没有办法将这3幅图像对齐并且彼此相邻?

谢谢

3 个答案:

答案 0 :(得分:1)

使用此

.footer{text-align:center;}

答案 1 :(得分:0)

给`text-align:center&#34; CSS样式到您的页脚。

 .footer{text-align:center;}

答案 2 :(得分:0)

执行此操作的一种方法是将img包装在p标记中,并将p标记设置为text-align:center;,如下所示:

<div class="footer">
    <hr>
    <p id="socmed">Connect Socially With Us:</p>
    <p class="center">
    <img id="fb" border="0" src="image/fb.png" alt="Facebook Fan Page">
    <img id="twitter" border="0" src="image/twitter.png" alt="Facebook Fan Page">
    <img id="youtube" border="0" src="image/youtube.png" alt="Facebook Fan Page">
     </p>
    <hr>
</div>


p.center{ text-align:center; }

JS小提琴:http://jsfiddle.net/9fBtf/2/