How to create a fixed background image on a web page.

Discussion in 'HTML & Website Design' started by philpbvc3232, Nov 7, 2010.

  1. #1
    How to create a fixed background image on a web page.please share your reply
     
    philpbvc3232, Nov 7, 2010 IP
  2. SuperVM

    SuperVM Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There's an easy CSS method to set a single image as the background; using z-index you can keep it on the bottom and automatically resized to the browser window.

    Here's a walk-through: http://css-tricks.com/perfect-full-page-background-image/
     
    SuperVM, Nov 7, 2010 IP
  3. radiant_luv

    radiant_luv Peon

    Messages:
    1,327
    Likes Received:
    34
    Best Answers:
    1
    Trophy Points:
    0
    #3
    
    body
    {
    background-image:url('background.jpg');
    background-repeat:no-repeat;
    [B]background-attachment:fixed;[/B] /* for fixed background image */
    }
    
    Code (markup):
    z-index is not used for positioning elements. It's the "position" property in css used to position elements. The z-index property specifies the stack order of an element.
    and z-index only works on positioned elements (position:absolute, position:relative, or position:fixed).
     
    Last edited: Nov 7, 2010
    radiant_luv, Nov 7, 2010 IP
  4. logoonlinepros

    logoonlinepros Member

    Messages:
    501
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    28
    #4
    Hey thanks a lot for share this code i will try it to my logo design site.
    Thanks for share about it.
     
    logoonlinepros, Nov 7, 2010 IP
  5. karthimx

    karthimx Prominent Member

    Messages:
    4,959
    Likes Received:
    127
    Best Answers:
    2
    Trophy Points:
    340
    #5
    body
    {
    background-image:url('background.jpg');
    background-repeat:no-repeat;
    }
    you can repeat the background by x axis or y axis by changing the above codes to

    body
    {
    background-image:url('background.jpg');
    background-repeat: repeat-x;
    }
     
    karthimx, Nov 8, 2010 IP
  6. helloguys12345678

    helloguys12345678 Greenhorn

    Messages:
    50
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    20
    #6
    or you can do it in one line:

    background: url(image.jpg) no-repeat fixed 0 0;
    Code (markup):
     
    helloguys12345678, Nov 8, 2010 IP