SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2002
    Location
    London, UK
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    background-position problem

    Hi,

    I have a straightforward rightnav CSS declaration:
    Code:
     
    #lcr #cont2 { 
    float:right;
    width: 620px; 
    background:#fff url(images/content_bg_blue.gif) repeat-y 0 30px;
    }
    Trouble is that, while I want the background image to start 30px from the top of the <div>, it refuses to do so once I ask it to repeat-y. If I replace the 'repeat-y' above with 'no-repeat', the image positions itself correctly...but naturally doesn't repeat!

    Does anyone know if background properties have to be declared in a certain order to work, or if there's anything obviously wrong with my code?

    The page where I'm using the CSS is at http://www.staff.city.ac.uk/~danj/de...age/test2.html

    Thanks for any advice.

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    When you repeat a background image it is repeated along the axis you specify but it repeats in both directions. So although it is starting at 30px down from the top it will then repeat upwards and downwards from that position.

    You will have to change your design to suit, such as using another element that starts from the position you want the background to repeat.

    Paul

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2002
    Location
    London, UK
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gotcha. Thanks Paul. (Although it does seem a touch daft that the image is repeated both ways along the axis, even if one specifies a 'starting' background position!)

  4. #4
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Although it does seem a touch daft
    Well I think it has to do with pattened images that you may want to start the pattern in a certain place to match your layout (e.g. in the centre). (

    Although it would be nice to have the option of starting at a certain position )

    Paul


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •