Starting and stopping css background at differnt points.

Discussion in 'CSS' started by Valiant, Feb 16, 2009.

  1. #1
    Hey, here is a diagram:
    [​IMG]

    The blue is the div, and the red the background:

    
    <style>
    #div{
      height: 50px;
      width: 500px;
      background-image: url("images/bg.jpg");
    }
    </style>
    <div id="container"></div>
    
    Code (markup):
    Any ideas how I can start and end the background a little way in ??

    Thanks.
     
    Valiant, Feb 16, 2009 IP
  2. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #2
    background-position allows you to position your background to start a little way in, you can either specify a position e.g top left, or an amount of px or a % e.g

    background-position: 50px 0;
    would start the background 50px in.

    As for ending the background a little way in you will just have to create your background to that size, unless there is no content after this background on the right then u can give the div a margin-right equal to the 50px.
     
    wd_2k6, Feb 16, 2009 IP
  3. Valiant

    Valiant Peon

    Messages:
    284
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ok, thanks.
     
    Valiant, Feb 21, 2009 IP