MMOCC the isometric world scene, 2006–now
Archive. Archived from the original MMOCC Forum (2006–2010), recovered from the Internet Archive. The forum is read-only history now — the scene talks on Discord. If you posted here and want something removed, get in touch.

How to vertically align in the dead center using CSS.

3 posts · 2007-02-27 · MyBB era
02-27-2007 11:44 AM #1
Original Source:
Quote:http://www.wpdfd.com/editorial/thebox/deadcentre4.html

This is the link - view source and css files.


Step one: Include the following CSS in your page.

Code:
<style type="text/css" media="screen"><!--
body
    {
    margin: 0px
    }

#horizon        
    {
    color: white;
    background-color: #0ff;
    text-align: center;
    position: absolute;
    top: 50%;
    left: 0px;
    width: 100%;
    height: 1px;
    overflow: visible;
    visibility: visible;
    display: block
    }

#content    
    {
    font-family: Verdana, Geneva, Arial, sans-serif;
    background-color: #f00;
    margin-left: -125px;
    position: absolute;
    top: -35px;
    left: 50%;
    width: 250px;
    height: 70px;
    visibility: visible
    }

.bodytext
    {
    font-size: 14px
    }


--></style>
    </head>

Step Two: Include the following code in the Body of your page.

Code:
<div id="horizon">
            <div id="content">
                <div class="bodytext">
                    This text is the dead center.
                </div>
            </div>
        </div>

Replace This text is the dead center with whatever you want aligned to the vertical center.

02-28-2007 10:47 AM #2
Very nice.

Will possibly use in the future.

+Rep of course.

03-02-2007 11:13 AM #3
This is a good tutorial! It shows you know what you're doing ^.^

You should note that the first part (the CSS) should be included in between the <head> and </head> tags, not just anywhere on the page.

Recovered from /printthread.php?tid=14282 · captured 2012.