Image URL In CSS

Discussion in 'CSS' started by gobbly2100, Jul 25, 2007.

  1. #1
    How do I put the image URL in this?

    .image-001
    {
    float:left;
    }
    Code (markup):
    I want to add a URL of the image in there.

    I am a complete noob so please be aware.
     
    gobbly2100, Jul 25, 2007 IP
  2. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #2
    Erm? If that's an image element that has a class of "image-001" then you don't need to supply a URL provided you use the SRC attribute and the image is *content* (article image). If that's just another element, then use the background-image property like so..

    background-image:url(foo.jpg);
     
    soulscratch, Jul 25, 2007 IP
  3. gobbly2100

    gobbly2100 Banned

    Messages:
    906
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have not been very clear atall actually sorry.

    I want to insert an image into that so that I no longer need an image in my HTML file if that makes sense.

    Look here at what I have so far: Huxley News

    I want that Nvidia image to remain where it is and still have the text wrap around it but I want to know how I can then add the image to the CSS instead.

    I hope that makes sense, since making the first post this is what my CSS is looking like:

    /* CSS Document */
    
    .nvidia-logo
    {
    url:('/images/Nvidia.gif');
    float:left;
    }
    Code (markup):
    Thanks for your help here!
     
    gobbly2100, Jul 25, 2007 IP
  4. Katy

    Katy Moderator Staff

    Messages:
    3,490
    Likes Received:
    513
    Best Answers:
    7
    Trophy Points:
    355
    #4
    /* CSS Document */

    .nvidia-logo
    {
    background-image: url('/images/Nvidia.gif');
    float: left;
    }

    then use:

    <div class="nvidia-logo"></div>
     
    Katy, Jul 25, 2007 IP
  5. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #5
    Please don't do it this way. That Nvidia logo is part of the content, since its relevant to the article and should not be used as a background-image. Leave it as an <img>. That is the right way to markup it up. Leave the float though.
     
    soulscratch, Jul 25, 2007 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #6
    Agreed, that is a non-presentational img, so it should be an img tag.
     
    deathshadow, Jul 25, 2007 IP
  7. gobbly2100

    gobbly2100 Banned

    Messages:
    906
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Ok I got you, thanks Katy for showing me how it is done because I will use the same code for the actual background anyway.

    So any images that are part of content I leave, that is cool I get it now.

    Thanks everyone, much appreciated :)

    P.S One question, on the div tags is there any other way of doing it such as <div class="img" /> or something?
     
    gobbly2100, Jul 25, 2007 IP
  8. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You'd have to use <div id="unique-ID"></div> and then have an individual ID for each background image you want to use.

    Then set a width and height (followed by overflow; hidden; to force IE 5 and 6 to treat height as height, rather than min-height) and apply your background image to that.
     
    Dan Schulz, Jul 25, 2007 IP