background-image in external css

G

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
 
J

John Saunders

Dan Nash said:
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...?

"_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.
 
N

nokiko

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...
 
G

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
 
G

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
 
G

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
 
G

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top