473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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
Nov 18 '05 #1
7 1659
"Dan Nash" <da*@musoswire.co.uk> wrote in message
news:9D**********************************@microsof t.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
Nov 18 '05 #2
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" <da*@musoswire.co.uk> wrote in message
news:9D**********************************@microsof t.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

Nov 18 '05 #3
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...
Nov 18 '05 #4
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...

Nov 18 '05 #5
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...

Nov 18 '05 #6
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...

Nov 18 '05 #7
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...

Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Stanimir Stamenkov | last post by:
Here are two cases regarding inline-level elements' line-height, padding and background, which I doesn't understand: <div style="background: black; color: white; line-height: 1.5">...
1
by: CMAR | last post by:
I have a design of a frameless page on my practice website: http://home.ne.rr.com/thespar/designerN.htm The idea is to have a #left navigation bar which is absolutely positioned and which...
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
2
by: bissatch | last post by:
Hi, I am running a w3c CSS validation check on a site in development. I have many errors saying that my CSS is not valid because I have not defined the background-color but instead left it...
6
by: Francois Bonzon | last post by:
Any idea how I can launch a background task from a PHP script? For example, when a user posts on my message board, it may fire many e-mail notifications to other users, and other tasks. I want...
0
by: Jeb Hunter | last post by:
Well, how can I describe this succinctly? I have a page with DIVs that us background images to produce a border effect. It works perfectly well, but I want to make up (for now) 3 different...
2
by: darkpowrjd | last post by:
I've been trying to create a new navigation system for my site, and I got everything figured out except for one thing. Here is the CSS code I'm using right now: body { font: normal 10px Verdana,...
8
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post by:
I'm trying to figure out how to modify a panel (panel1) from a backgroundworker thread. But can't get the panel to show the new controls added by the backgroundwork task. Here is my code. In...
7
by: arupfrancis | last post by:
Hi, I am trying to create a colored box using background images. I am able to do it easily using tables but doing it in divs is proving to be an issue. Moreover IE and Mozilla also seems to be...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.