![]() |
background-image in external css
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 |
Re: background-image in external css
"Dan Nash" <dan@musoswire.co.uk> wrote in message
news:9DCE1476-E07C-4835-80C0-0F17AAE27F57@microsoft.com... > 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. -- John Saunders johnwsaundersiii at hotmail |
Re: background-image in external css
Thanks John,
You're dead on. Path was wrong. It was actually pointing at http://website/_shared/_css/_img/backtest.jpg - not much good! A simple "../../" sorted it! :o) Thanks a lot! Dan "John Saunders" wrote: > "Dan Nash" <dan@musoswire.co.uk> wrote in message > news:9DCE1476-E07C-4835-80C0-0F17AAE27F57@microsoft.com... > > 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. > -- > John Saunders > johnwsaundersiii at hotmail > > > |
Re: background-image in external css
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... |
Re: background-image in external css
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. :o) Cheers Dan "Armand" wrote: > 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... > |
Re: background-image in external css
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. :o) Cheers Dan "Armand" wrote: > 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... > |
Re: background-image in external css
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. :o) Cheers Dan "Armand" wrote: > 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... > |
Re: background-image in external css
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. :o) Cheers Dan "Armand" wrote: > 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... > |
| All times are GMT. The time now is 11:11 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.