View Single Post
Old 07-16-2004, 08:43 AM   #1 (permalink)
Silvy
paranoid
 
Silvy's Avatar
 
Location: The Netherlands
[html/css] vertical centering...

Hi,

I'd like to have a single block of text on a page, centered vertically and horizontally. (using css)

The last part is easy: text-align: center;

but the vertical centering is eluding me. Can anyone help?
So far I haven't been able to vertically center anything...

current code (index.html) :
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<
html>
    <
head>
        <
meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
        <
link rel="stylesheet" type="text/css" href="test.css" />
        <
title>
            
CSS test
        
</title>

    </
head>
    <
body>
        <
div class="centerthis">
            
Centered text
        
</div>
    </
body>
</
html
css:
PHP Code:
body {
    
min-height:    100%;
    
min-width:    100%;
    
vertical-alignmiddle;
    }


.
centerthis {
    
text-align:    center;
    
width:    100%;
    
height:    100%;
    
vertical-align:    middle;
    
font-weight:    bold;
    } 
The text is displayed bold and horizontally centered so the CSS is included and parsed correctly.
Any tips (on this and CSS general) greatly appreciated!
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. "
- Murphy MacManus (Boondock Saints)
Silvy is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62