2012-11-21 51 views
0

为参考:检查: http://jsfiddle.net/blackvibes/mVYwd/我需要一个img垂直居中在一个div,如何?

我创建了移动网站(这是很肯定不能做到这一点的最好方式..但无论如何)我使用百分比一路,因为它在任何移动(人像)屏幕上的尺寸应该相当相等。

我试过numberous的东西,如:

#header img { 
vertical-align:middle; 
padding-top: auto; 
padding-bottom: auto; 
margin-top: auto; 
margin-bottom: auto; 

}

但我仍然不能得到它的工作。

唯一会在那个div中的是那个呈现学校标志的单个图像。

在此先感谢!从IMG标记

回答

0

用你的形象,你的#header ID背景:

#header img { 
    background:url(your_image.jpg) center center no-repeat; 
} 
0

删除widthheight

#header{text-align:center;}