Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    60
    Thanks
    32
    Thanked 0 Times in 0 Posts

    CSS - background-image external

    Hi,

    I am getting to grips with CSS and am experimenting with it without getting hosting and using FTP, then using notepad and validating software, then viewing the changes in my browser.

    Obviously I'd like to make use of the background-image value quite a bit for my various <div> sections, however am OK with using external images to play around...The thing is, how do I reference external in CSS??

    I understand I use:-

    background-image:url (anexample.jpg);

    For internal (do I need quotations around 'anexample.jpg' above?)

    How do I modify this so I can play around with external images please?

    Thanks

  • #2
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Quote Originally Posted by adamwestrop View Post
    How do I modify this so I can play around with external images please?
    try specifying the full pathname to the external image starting with http://..........

  • Users who have thanked bullant for this post:

    adamwestrop (08-13-2011)

  • #3
    Regular Coder
    Join Date
    Jul 2011
    Location
    India
    Posts
    496
    Thanks
    3
    Thanked 57 Times in 56 Posts
    Use absolute path in case your are using images from Internet :like

    Code:
    .yourclass {
    background:URL('http://www.abcwebsite/images/yourimage.png');
    }
    Use relative path for the images placed on same server/folder from where your site is hosted. Like

    Code:
    .yourclass {
    background:URL('images/yourimage.png');
    }

  • Users who have thanked vikram1vicky for this post:

    adamwestrop (08-13-2011)

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,932
    Thanks
    6
    Thanked 1,041 Times in 1,014 Posts
    Quote Originally Posted by bullant View Post
    try specifying the full pathname to the external image starting with http://..........
    For example: background: url(http://example.com/images/anexample.jpg);

    Be aware, however, to not use images from other sources without asking the owner as image hotlinking is frowned upon.

  • Users who have thanked VIPStephan for this post:

    adamwestrop (08-13-2011)

  • #5
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Quote Originally Posted by VIPStephan View Post
    Be aware, however, to not use images from other sources without asking the owner as image hotlinking is frowned upon.
    yep, and not to mention that if the owner finds out their images are being hot-linked, they could replace those images with images you normally wouldn't want displayed on the website doing the hot-linking to external images


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •