Ultrashock Forums > Development > Client Side
CSS - vertically aligning body background images
Member Blogs
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
CSS - vertically aligning body background images
Old 2008-03-25

How can I vertically align a background image for the page body so that it will always appear in the middle and have equal space above and below the image? I tried using centre and 50% but it just moves the image to the top and then hides 50 half of it out of sight.
FredVaux.com | LightFused.net
postbit arrow 1 comment | 747 views postbit arrow Reply: with Quote   
flashkicks
Registered User
flashkicks is offline
seperator
Posts: 633
2005-06-17
Age: 20
flashkicks lives in United Kingdom
seperator

Ultrashock Member Comments:
Nutrox's Avatar Nutrox Nutrox is offline Nutrox lives in United Kingdom 1 Blog Entries 13 Creative Assets 2008-03-25 #2 Old  
Set the HTML height to 100% and add the background image to that.

Code:
html
{
    height:100%;
    background:#FFFFFF url( myimage.jpg ) no-repeat fixed center center;
}
That has always worked for me.
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: