1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Question about text on background images

Discussion in 'HTML & Website Design' started by samie, Sep 11, 2011.

  1. #1
    Hi,

    I was just wondering if someone could shed some light on background images with text on them. I noticed when trying to add a padding to text within background images, it adds width to the images and the image jumps around. I know some workarounds for it like... no-repeat on the image, and putting divs within divs. But I was just wondering what you guys had for feedback on this and what would be the correct procedure.
     
    Solved! View solution.
    samie, Sep 11, 2011 IP
  2. xira

    xira Active Member

    Messages:
    315
    Likes Received:
    8
    Best Answers:
    4
    Trophy Points:
    68
    #2
    margins? Have yo tried margins instead of padding?
     
    xira, Sep 12, 2011 IP
  3. ChingChing

    ChingChing Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    can u post some code?
     
    ChingChing, Sep 12, 2011 IP
  4. #4
    If you are setting a background image to an element with a fixed with and want your text placement to be in a specific area, you can do 2 things easily...

    1 - Use the padding XXpx count and subtract the padding amount from the overall width of the element. For example if it's a <p> and you apply padding: 0px 20px 0px 20px; to it and the overall width of the <p> is 200, you need to set the width: 160px;

    160 + 20 + 20 = 200

    2 - Place the text in an element within an element... <div><p></p></div> - Setting <div> to fixed width and using margin spacing on your <p> appropriately.
     
    workingsmart, Sep 14, 2011 IP
    samie likes this.
  5. samie

    samie Member

    Messages:
    269
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    45
    #5
    Thank you guys! And "workingsmart", your summary is what I am looking for. I guess tha'ts pretty much what I've been having to do all along but I just thought it was an odd way of doing things, but now I know it is correct :) Thank you!!!!!!
     
    samie, Sep 15, 2011 IP
    workingsmart likes this.
  6. unknownpray

    unknownpray Active Member

    Messages:
    3,831
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    70
    #6
    If divs within divs work then why would you like to experiment? The thing works like a charm. Used it to solve a large number of my problems. And you don't have to worry about things get out of control due to this.
     
    unknownpray, Sep 15, 2011 IP
  7. woody allen

    woody allen Peon

    Messages:
    263
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    have your tried absolute positioning tag? it works perfectly for me. else, you can try indexing them for position.
     
    woody allen, Sep 19, 2011 IP
  8. maketick

    maketick Peon

    Messages:
    155
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I hope that you got your answer and thanks it will also help others to learn something.
     
    maketick, Sep 23, 2011 IP