CSS in .NET 2005

C

czuvich

I am having an issue with an external css file. I am trying to get a
background image to show up in the browser using the background-image
url property. The code I have works fine for most users, but for some,
the image does not show up. Here are my scenarios..

Here's the external css..

#companylogo
{
background-image: url(/images/SWNheader.jpg);
height: 70px;
}

Here's the html snippet...

<div id="companylogo"></div>

The reason why I am using the /images is due to our folder structure.
Here's our production web server structure.

inetpub/wwwroot/images
inetpub/wwwroot/applicationdirectory/app_themes/styles.css

The image comes up fine for all users now, but in the IDE in debug
mode, it does not come up. The image folder is present and my
application is running under the same directory structure. I am
wondering if it has something to do with that port it runs on whenever
you run it in debug.

Here's what I have also tried...

#companylogo
{
background-image: url(http://localhost/images/SWNHeader.jpg);
height: 70px;
}


Now, the image comes up fine on my local machine, but for some users in
the production environment it doesn't display the image. It's just
blank. If someone could maybe guide me to a way to display the image on
both environments (local and production). I know it's got to be
something simple since surely other environments have this same setup.
Thanks!
 
C

czuvich

Didn't work. It didn't find the image. I always thought that the ../
was relative to the css file. However, when putting the / in front, it
seems to be relative to the wwwroot directory. Is that right?
 
S

Sean Chambers

just fyi,

background images in a css file are reletive to the css file's path.
That might help you

sean
 
C

czuvich

Well,

What I am not understanding is why the image shows up on all PC's
whenever you put "http://servername" as opposed to "http://localhost".
I am trying to keep a css file consistent in case we change servers. If
the background images are relative to the css file's path, then why is
it when debugging in .net, "/images/name" does not display the image?
But whenever it is deployed to a server, it works fine? Thanks in
advance.
 
C

czuvich

I suppose here's my real question. What do I put in my .css file to get
the header.jpg to display correctly under the following directory
structure.

wwwroot/images/header.jpg
wwwroot/application/app_themes/themename/styles.css

Thank you.
 

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,774
Messages
2,569,599
Members
45,170
Latest member
Andrew1609
Top