a background code I am unable to repeat!

Discussion in 'HTML & Website Design' started by Majo0od, Aug 24, 2009.

  1. #1
    Hey guys

    Here is a code that I have, and I tried countless times to get it to repeat through x, but after countless attempts, each one was a failure.

    echo "<div id='greenheader' style=\"background-repeat:repeat-x;""background-image:url('../images/headerrep4.png'); width:1px;height:109px\">";

    How do I get this to repeat through x?

    Thanks in advance
     
    Majo0od, Aug 24, 2009 IP
  2. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #2
    not sure what that looks like in the browser (important, look at how it is echoed in your browser! it must look like
    <div id="greenheader" style="background-repeat:repeat-x; background-image:url(../images/headerrep4.png); width:1px;height:109px"> in the browser!! when you do View>View Source)

    I think your repeat is getting through but your image isn't, because for whatever reason you have " between the two background statements.
    Also you are repeating horizontally, but your width is only 1px... did you meant to repeat vertically? I think you did.

    Ideally you can also set all your background statements into one:
    background: url(../images/headerrep4.png) repeat-y;

    Notes: you don't need to quote the url path for the image (so one less set of quotes to worry about). Whatever style of quotes you use for the id's and classes of divs, use for other attributes too like style. So if you choose singles, use singles, if you use doubles, use doubles. Don't mix and match, that's a good way to get them mixed and not working, esp since you're writing this through echo statements. I noticed your id was single quotes but your style attribute was double quotes.

    Ideally there would be no inline style attribute but you would be using CSS separately... but that's another topic.
     
    Stomme poes, Aug 24, 2009 IP
  3. Majo0od

    Majo0od Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hey,

    Well, no I was planning on repeating horizontally, because the images being repeated is a sort of a gradient, and I want that to be repeated as a background horizontally... Also, I tired putting the background statements into one, but it doesn't repeat, it only shows the background, and that's it... so what can I do?
     
    Majo0od, Aug 24, 2009 IP
  4. ExtremeData

    ExtremeData Well-Known Member

    Messages:
    450
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    125
    #4
    Remove width:1px; and should work.
     
    ExtremeData, Aug 24, 2009 IP
  5. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #5
    yup. Why I thought you wanted to repeat up and down, because the size you've put on the element with the bg image is only 1px wide and very tall. So switch your width and height declarations around.

    A background cannot extend beyond its element's borders, unlike an HTML child <img>.
     
    Stomme poes, Aug 24, 2009 IP
  6. Majo0od

    Majo0od Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    it worked, thanks guys!
     
    Majo0od, Aug 26, 2009 IP