css & body background image

Last post 11-07-2009 2:04 PM by _kalesh_. 2 replies.

Sort Posts:

  • css & body background image

    11-03-2009, 1:09 PM
    • Participant
      1,282 point Participant
    • misuk11
    • Member since 08-05-2003, 6:40 AM
    • Posts 746

    I have some css that specifies an image as the background for the page body

     

    body 
    {
    	background-image: url(../images/EBSMainBackground.jpg);
    	background-repeat: no-repeat;
    	background-position: left bottom;
    	font-family: Trebuchet MS;
    	font-size: 12px;
    	background-attachment: scroll;
    }


     

    this works fine until I maximise the width of my web page and the image cuts off horizontally (obviously the width of the image is less than the full page width)

    Is there a way with CSS that will stretch the background image so that it will always fit the whole page width no matter what size ?

  • Re: css & body background image

    11-03-2009, 1:14 PM
    Answer
    • Participant
      845 point Participant
    • crawford.r
    • Member since 08-10-2009, 3:01 PM
    • Posts 169

    No, currently that is not supported:

    http://www.webmasterworld.com/forum83/303.htm
    http://webdesign.about.com/od/css3/f/blfaqbgsize.htm

    Hopefully it will be supported with CSS 3.

  • Re: css & body background image

    11-07-2009, 2:04 PM
    • Member
      462 point Member
    • _kalesh_
    • Member since 10-23-2007, 7:30 AM
    • Posts 110

    There is a trick most web designers use:

    Repeat-x css property. That way your small image will cover the entire area along the x axis (horizontally).

    For eg take a look at this website. http://tonyyoo.com/v2/

    If you have a large monitor ~ 22". The background image will seem to be a large one, but infact its 428px × 546px. The image just repeats itself along the x axis.

    This trick works when the background image has a symmetry.

    This website uses a 1px width image for the background. http://www.awarespot.com/

    Aseem \../ (-_-) \./ Gautam
    "Do right and fear no man."
Page 1 of 1 (3 items)