background-image in external css

Discussion in 'ASP .Net' started by Guest, Aug 2, 2004.

  1. Guest

    Guest Guest

    Hi

    I'm trying to create an external stylesheet for use in my Web App. It works fine, and I've got it linked and everything. The only problem is the "background-image" property isn't working.

    I've selected the iamge through VS, and its in the _images/ subdir. The code that VS created is as follows:

    background-image: url(_images/back.jpg)

    Yet it doesn't work. The image appears in the CSS style editor, but when I run my app in the browser, no image is displayed. All other tags seem fine though. Any ideas...?

    Cheers


    Dan
     
    Guest, Aug 2, 2004
    #1
    1. Advertisements

  2. works fine, and I've got it linked and everything. The only problem is the
    "background-image" property isn't working.
    code that VS created is as follows:
    run my app in the browser, no image is displayed. All other tags seem fine
    though. Any ideas...?

    "_images/back.jpg" is a relative URL. I bet that in the style editor, it is
    relative to the page, but that when the external stylesheet is used, the URL
    is taken to be relative to the URL of the external stylesheet. For instance,
    if the stylesheet was at http://site/styles/mycss.css, then I bet that the
    image URL would mean http://site/styles/_images/back.jpg.

    Just a guess. Try an absolute URL just to see what happens.
     
    John Saunders, Aug 2, 2004
    #2
    1. Advertisements

  3. Guest

    Guest Guest

    Guest, Aug 3, 2004
    #3
  4. Guest

    nokiko Guest

    Hi

    your css is invalid

    background: url(whatever.jpg);

    **********************************************************************
    Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
    Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
     
    nokiko, Aug 3, 2004
    #4
  5. Guest

    Guest Guest

    Hi Armand

    My CSS now reads...

    background-image: url(../../_img/backtest.jpg);

    I wonder if you could tell me how this is invalid? If (as you mentioned) my code read

    background-image: url(backtest.jpg);

    That would mean that my JPG file would have to be located in the _shared/_css folder, which, I'm sure you'll agree makes for a very messy and confusing directory structure. For my CSS to work from it's location, I need to get back to the root and find _img/backtest.jpg. So.. how do I do that without making it invalid?

    If, As John suggested, I use an absolute reference, I get

    background-image: url(http://localhost/DearPrimeMinister/_img/backtest.jpg);

    I'm assuming that when I move my project to my web server, all the links will be invalid, because all the links point to localhost rather than www.mysite.com. Unless of course localhost works on Win2k3 servers as well...?

    Can you clarify, just so I know I'm doin it right. :eek:)

    Cheers


    Dan
     
    Guest, Aug 3, 2004
    #5
  6. Guest

    Guest Guest

    Hi Armand

    My CSS now reads...

    background-image: url(../../_img/backtest.jpg);

    I wonder if you could tell me how this is invalid? If (as you mentioned) my code read

    background-image: url(backtest.jpg);

    That would mean that my JPG file would have to be located in the _shared/_css folder, which, I'm sure you'll agree makes for a very messy and confusing directory structure. For my CSS to work from it's location, I need to get back to the root and find _img/backtest.jpg. So.. how do I do that without making it invalid?

    If, As John suggested, I use an absolute reference, I get

    background-image: url(http://localhost/DearPrimeMinister/_img/backtest.jpg);

    I'm assuming that when I move my project to my web server, all the links will be invalid, because all the links point to localhost rather than www.mysite.com. Unless of course localhost works on Win2k3 servers as well...?

    Can you clarify, just so I know I'm doin it right. :eek:)

    Cheers


    Dan
     
    Guest, Aug 3, 2004
    #6
  7. Guest

    Guest Guest

    Hi Armand

    My CSS now reads...

    background-image: url(../../_img/backtest.jpg);

    I wonder if you could tell me how this is invalid? If (as you mentioned) my code read

    background-image: url(backtest.jpg);

    That would mean that my JPG file would have to be located in the _shared/_css folder, which, I'm sure you'll agree makes for a very messy and confusing directory structure. For my CSS to work from it's location, I need to get back to the root and find _img/backtest.jpg. So.. how do I do that without making it invalid?

    If, As John suggested, I use an absolute reference, I get

    background-image: url(http://localhost/DearPrimeMinister/_img/backtest.jpg);

    I'm assuming that when I move my project to my web server, all the links will be invalid, because all the links point to localhost rather than www.mysite.com. Unless of course localhost works on Win2k3 servers as well...?

    Can you clarify, just so I know I'm doin it right. :eek:)

    Cheers


    Dan
     
    Guest, Aug 3, 2004
    #7
  8. Guest

    Guest Guest

    Hi Armand

    My CSS now reads...

    background-image: url(../../_img/backtest.jpg);

    I wonder if you could tell me how this is invalid? If (as you mentioned) my code read

    background-image: url(backtest.jpg);

    That would mean that my JPG file would have to be located in the _shared/_css folder, which, I'm sure you'll agree makes for a very messy and confusing directory structure. For my CSS to work from it's location, I need to get back to the root and find _img/backtest.jpg. So.. how do I do that without making it invalid?

    If, As John suggested, I use an absolute reference, I get

    background-image: url(http://localhost/DearPrimeMinister/_img/backtest.jpg);

    I'm assuming that when I move my project to my web server, all the links will be invalid, because all the links point to localhost rather than www.mysite.com. Unless of course localhost works on Win2k3 servers as well...?

    Can you clarify, just so I know I'm doin it right. :eek:)

    Cheers


    Dan
     
    Guest, Aug 3, 2004
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.