Alex Rivera | Logout

how to put image in center of html page?

Asked 2012-06-26T11:13:53.933
14

Possible Duplicate:
How to center div horizontally and vertically

I need to put image in center of html page, both vertical and horizontal ... been trying few stuff but seems to work fine. To get horizontal alignment I used <body style="text-align:center">

and it works fine, but what do with vertical alignment?

regards

Edit
Report

1 Answer

9

Put your image in a container div then use the following CSS (changing the dimensions to suit your image.

.imageContainer{
        position: absolute;
        width: 100px; /*the image width*/
        height: 100px; /*the image height*/
        left: 50%;
        top: 50%;
        margin-left: -50px; /*half the image width*/
        margin-top: -50px; /*half the image height*/
    }
answered 2012-06-26T13:15:25.143

Your Answer