Search code examples
asp.netcsspage-layout

My master page has empty space on the bottom and right side. Can I "center" my master page and set a background image?


Here's how it looks like right now:

my screenshot

Is there a way for me to center the area that has content, and place a repeating background image so the site doesn't look so empty?


Solution

  • Centering horizontally can be accomplished by wrapping the content you wish to center in a div, and applying the style:

    margin-left: auto;
    margin-right: auto;
    

    to said div.

    This will take care of your issue of space on the right. You can place a background image (repeating or not) using CSS as well.

    Your larger issue will be the vertical centering. As far as I'm aware, there's (currently) no easy, cross-browser (including IE6/7) way of accomplishing that. I'd like to be proven wrong here by another user, though. :)