W3C home > Mailing lists > Public > www-style@w3.org > July 2003

Center DIV

From: Jonas Galvez <jonas@onrelease.org>
Date: Thu, 3 Jul 2003 11:18:36 -0300
Message-ID: <011101c3416e$015dfa50$c987cec8@particuljqcbxr>
To: <www-style@w3.org>

Hi, this is my first post on this list. Does anybody know 
an efficient way to place a <div> on the center of the 
page? I've tried everything. I read an article over @ 
mrclay.org (url below) and the technique he teaches seems 
to be the perfect approach (in terms of CSS), but 
unfortunately, it doesn't work in IE.

http://mrclay.org/web_design/centered_image/

The *solution* I found was to position the image at 50% of 
the page and then compensate with a negative margin (with 
half of the size of the image). For example:

<head>
    <style type="text/css">
    <!--
    div.icon {
        position: absolute;
        margin-top: -20px;
        margin-left: -20px;
        top: 50%; left: 50%;
    }
    -->
    </sytle.
</head>
<body>
    <div class="icon">
        <img src="image.gif" alt="Image" />
    </div>
</body>

Any advice would be highly appreciated... :)



--
Jonas Galvez
www.jonasgalvez.com
www.macromedia.com/go/team
Received on Thursday, 3 July 2003 10:08:58 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:22 GMT