Using CSS To Put Text Over An Image

Discussion in 'CSS' started by instant87, Oct 19, 2009.

  1. #1
    I'm looking to put two different pieces of text over a background image. I attached the background image (the height/width measurements are exact).

    I want it to be something like <div id="title">Top 2009 Products</div> for the top portion of the background, and then below the header, be something like <div id="review">the top products are... blah blah.. blah</div>

    Again, I was wondering if this could be done with css... and if so what would be the code? Thanks!
     

    Attached Files:

    instant87, Oct 19, 2009 IP
  2. Design_Guy

    Design_Guy Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi there!

    This following code should work, with a little tweaking.

    
    .textimage {
      background-image: url('THE IMAGE');
      height: 316px;
      width: 187px;
    }
    #title {
      padding: 4px 0 0 10px;
    }
    #review {
      padding: 10px 0 0 10px;
    }
    
    Code (markup):
    
    <div class="textimage">
    <p id="title">The Title</p>
    <p id="review">The Review</p>
    </div>
    Code (markup):
    If you get stuck for what to do, I also wrote an article on this at: http://www.html-tips.net/css-text-over-an-image/
     
    Design_Guy, Oct 21, 2009 IP
  3. 3mints.info

    3mints.info Well-Known Member

    Messages:
    344
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    135
    #3
    Design_Guy, what's the different between "class" and "ID"??
     
    3mints.info, Oct 21, 2009 IP
  4. Design_Guy

    Design_Guy Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi 3mints,

    A class can be used many times, while an id can only be defined once in a HTML page.
    Also, in the CSS you use a period at the start of a class and a hash sign at the start of an id.
     
    Design_Guy, Oct 21, 2009 IP
  5. 3mints.info

    3mints.info Well-Known Member

    Messages:
    344
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    135
    #5
    Thank you :)
     
    3mints.info, Oct 22, 2009 IP