Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Senior Member duck444's Avatar
    Join Date
    Feb 2003
    Location
    east coast
    Posts
    402
    Member #
    751
    Liked
    2 times
    Can anyone tell me how I can link to all my images in a css documanet using:

    {background: url(IMAGELINK)
    no-repeat;} ?


    This works fine for the top banner of my site (and it's obviously easier to update images this way) but when I try to use it for all the other images on my site they don't show up. So, in the meantime, I've been forced to revert back to:

    <img src="IMAGELINK"> in the html pages.

    Can anyone tell me what I'm doing wrong?

    This is the code I use for example:

    On the html pages I place the div, with its identifier where I want the image to appear, like so:

    <div id="bumper"></div>

    And then in the css I add the image, like so:

    #bumper {
    {background: url(IMAGELINK)
    no-repeat;


    }

    This works for my banner but not my other images.

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    That should be fine, but you also have to set an explicit width and height, otherwise the div will resize to its contents, which consist of nothing.

    Is there a reason you're replacing *all* of your images with CSS, though?

  4. #3
    Senior Member duck444's Avatar
    Join Date
    Feb 2003
    Location
    east coast
    Posts
    402
    Member #
    751
    Liked
    2 times
    Sorry it took a day to reply, Shadowfiend.

    Well, I'm not replacing the images, just the kind of code used to display them. I don't see much of anyone using this, <img src="">, anymore so I thought I would try to keep my code up to standards.....and also make my images easier to replace (should I ever need to) in the future.

  5. #4
    Senior Member Stylise's Avatar
    Join Date
    Jul 2005
    Location
    Mount Martha, Australia
    Posts
    229
    Member #
    10679
    Not all images need to be CSS. Basically just 'background' images, meaning anything you want text/content to be on top off.

    You want to seperate your 'design images' from your 'content images', as CSS removes design from content.

  6. #5
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    The other situation where you would definitely want to use CSS images is if you want to achieve rollovers, since doing rollovers with images seems a better solution than the old method. It can be difficult to decide when to embed the image directly and when to make it a background on a div, but I daresay there are few pages that should have ONLY backgrounded images.

    Basically, things like navigation and titles lend themselves to background images, whereas when you want to include a picture in an article, that should be an img tag. Content vs design, as Stylise said.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:45 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com