2012-07-20 48 views
1

我正在为构建在html5和css3中的应用程序创建初始屏幕,并且我无法将图像准确地置于中间。我需要它在手机和平​​板电脑中间。感谢您的任何建议或帮助。手机和平板电脑的定心图像

影像尺寸为300 x 300像素

回答

2

正如你所知道的图像的大小,你可以使用切缘阴性:

position: absolute; 
left: 50%; 
top: 50%; 
margin-left: -150px; 
margin-top: -150px; 
0

图片/块元素可以用利润为中心:

img { 
    margin-left: auto; 
    margin-right: auto; 
    display: block; 
    } 

否则,你可以使用老派<center>标签技术。它仍然在HTML5中。 ;)

相关问题