在页面中央显示图像 [英] Display the image in the center of the page

查看:78
本文介绍了在页面中央显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张图片-正在加载图片.

I have a image -- a loading image.

我希望该图像显示在页面中央. 我该怎么办?

I want that image to be displayed in the center on the page. How can I do that?

我写的代码是:

img.loading
    {
        position:absolute;
        left:0px;
        top:0px;
        z-index:1;
    }

如何使该图像始终显示在页面中央?

How can i make this image always be displayed in the center of the page?

推荐答案

发现了这一点:

Found this: How to Center an Image Perfectly in CSS, might help.

#img
{
    position:absolute;
    width:592px; /*image width */
    height:512px; /*image height */
    left:50%; 
    top:50%;
    margin-left:-296px; /*image width/2 */
    margin-top:-256px; /*image height/2 */
}

这篇关于在页面中央显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆