473,699 Members | 2,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

background-image problem while using CSS for aspx page

I am using background-image attribute in a CSS file and linking the
CSS file to aspx page. But strangly, background-image attribute is not
working for relative URL.

e.g. If I apply following css
..navbar-background {
background-image: url(images/menubar.gif);
}

the image is not appearing on the page. It seems that IE is picking
the image path relative to aspx file (instead of CSS file!)

If i change the CSS to
..navbar-background {
background-image: url(http:\\myse rver\cp\images\ menubar.gif);
}
then it's working.
What is the problem here?? Can someone please explain?
[Note: I am using IE6]

regards,
Nilesh Dhakras.
Nov 18 '05 #1
7 5123
Hi Nilesh,

try making the changes as follows. its the problem with the relative path i
assume that your images folder is in the root directory.

e.g. If I apply following css
..navbar-background {
background-image: url(~/images/menubar.gif);
}

HTH
Regards
Ashsih M Bhonkiya

"Nilesh" <dh*******@hotm ail.com> wrote in message
news:ae******** *************** ***@posting.goo gle.com...
I am using background-image attribute in a CSS file and linking the
CSS file to aspx page. But strangly, background-image attribute is not
working for relative URL.

e.g. If I apply following css
.navbar-background {
background-image: url(images/menubar.gif);
}

the image is not appearing on the page. It seems that IE is picking
the image path relative to aspx file (instead of CSS file!)

If i change the CSS to
.navbar-background {
background-image: url(http:\\myse rver\cp\images\ menubar.gif);
}
then it's working.
What is the problem here?? Can someone please explain?
[Note: I am using IE6]

regards,
Nilesh Dhakras.

Nov 18 '05 #2
Hi, Nilesh Dhakras,

The paths should be relative to the .css file. Are you sure you are not
seeing a cached version of the .css (the one cached in the browser)? Try to
hit Ctrl+F5 to force the browser to request everything.

Also, make sure you don't have any error in the css style - if there is an
error you will not be shown any error messages, simply there will be no
styles applied to the control.

Hope this helps
Martin
"Nilesh" <dh*******@hotm ail.com> wrote in message
news:ae******** *************** ***@posting.goo gle.com...
I am using background-image attribute in a CSS file and linking the
CSS file to aspx page. But strangly, background-image attribute is not
working for relative URL.

e.g. If I apply following css
.navbar-background {
background-image: url(images/menubar.gif);
}

the image is not appearing on the page. It seems that IE is picking
the image path relative to aspx file (instead of CSS file!)

If i change the CSS to
.navbar-background {
background-image: url(http:\\myse rver\cp\images\ menubar.gif);
}
then it's working.
What is the problem here?? Can someone please explain?
[Note: I am using IE6]

regards,
Nilesh Dhakras.

Nov 18 '05 #3
It's been my experience that the url property is always relative to the page
not the stylesheet.
I've checked both MSDN and W3C spec but they don't seem to discuss about the
url attribute in detail.

Jiho

"Martin Dechev" <de*******@hotm ail.com> wrote in message
news:uk******** ******@TK2MSFTN GP09.phx.gbl...
Hi, Nilesh Dhakras,

The paths should be relative to the .css file. Are you sure you are not
seeing a cached version of the .css (the one cached in the browser)? Try to hit Ctrl+F5 to force the browser to request everything.

Also, make sure you don't have any error in the css style - if there is an
error you will not be shown any error messages, simply there will be no
styles applied to the control.

Hope this helps
Martin
"Nilesh" <dh*******@hotm ail.com> wrote in message
news:ae******** *************** ***@posting.goo gle.com...
I am using background-image attribute in a CSS file and linking the
CSS file to aspx page. But strangly, background-image attribute is not
working for relative URL.

e.g. If I apply following css
.navbar-background {
background-image: url(images/menubar.gif);
}

the image is not appearing on the page. It seems that IE is picking
the image path relative to aspx file (instead of CSS file!)

If i change the CSS to
.navbar-background {
background-image: url(http:\\myse rver\cp\images\ menubar.gif);
}
then it's working.
What is the problem here?? Can someone please explain?
[Note: I am using IE6]

regards,
Nilesh Dhakras.


Nov 18 '05 #4
Well, it's mentioned in the CSS1 specifications:

http://www.w3.org/TR/REC-CSS1.html#url

Quote:
Partial URLs are interpreted relative to the source of the style sheet, not
relative to the document

Greetings
Martin
"Jiho Han" <ji******@infin ityinfo.com> wrote in message
news:eb******** ******@TK2MSFTN GP12.phx.gbl...
It's been my experience that the url property is always relative to the page not the stylesheet.
I've checked both MSDN and W3C spec but they don't seem to discuss about the url attribute in detail.

Jiho

"Martin Dechev" <de*******@hotm ail.com> wrote in message
news:uk******** ******@TK2MSFTN GP09.phx.gbl...
Hi, Nilesh Dhakras,

The paths should be relative to the .css file. Are you sure you are not
seeing a cached version of the .css (the one cached in the browser)? Try

to
hit Ctrl+F5 to force the browser to request everything.

Also, make sure you don't have any error in the css style - if there is an error you will not be shown any error messages, simply there will be no
styles applied to the control.

Hope this helps
Martin
"Nilesh" <dh*******@hotm ail.com> wrote in message
news:ae******** *************** ***@posting.goo gle.com...
I am using background-image attribute in a CSS file and linking the
CSS file to aspx page. But strangly, background-image attribute is not
working for relative URL.

e.g. If I apply following css
.navbar-background {
background-image: url(images/menubar.gif);
}

the image is not appearing on the page. It seems that IE is picking
the image path relative to aspx file (instead of CSS file!)

If i change the CSS to
.navbar-background {
background-image: url(http:\\myse rver\cp\images\ menubar.gif);
}
then it's working.
What is the problem here?? Can someone please explain?
[Note: I am using IE6]

regards,
Nilesh Dhakras.



Nov 18 '05 #5
Hi Nilesh

I am sorry to provide this incorrect information in my last reply

actually the the paths should be relative to the .css file. and thats what the specifications says

"Well, it's mentioned in the CSS1 specifications
http://www.w3.org/TR/REC-CSS1.html#url

----- Ashish M Bhonkiya wrote: ----

Hi Nilesh

try making the changes as follows. its the problem with the relative path
assume that your images folder is in the root directory

e.g. If I apply following cs
..navbar-background
background-image: url(~/images/menubar.gif)
HT
Regard
Ashsih M Bhonkiy

"Nilesh" <dh*******@hotm ail.com> wrote in messag
news:ae******** *************** ***@posting.goo gle.com..
I am using background-image attribute in a CSS file and linking th
CSS file to aspx page. But strangly, background-image attribute is no
working for relative URL
e.g. If I apply following cs

.navbar-background
background-image: url(images/menubar.gif)
the image is not appearing on the page. It seems that IE is pickin

the image path relative to aspx file (instead of CSS file!
If i change the CSS t

.navbar-background
background-image: url(http:\\myse rver\cp\images\ menubar.gif)

then it's working
What is the problem here?? Can someone please explain
[Note: I am using IE6
regards

Nilesh Dhakras


Nov 18 '05 #6
Hi Martin,

Thanks a lot for your inputs. But I am really facing strange behavior.

I have a base CSS which is having this class
..navbar-background {
background-image: url(images/menubar.gif);
}
The base CSS is working just as expected (and as you explained). The
images are getting picted relative to the CSS file's directory (and
not the page's directory).

But when I create another custom CSS, and override this class in that
CSS, then the problem comes. My custom CSS has exactly same class but
with diff path (as it's placed in a diff directory than the base CSS).
In the page's <HEAD> section, I am mentioning the custion CSS after
the base CSS (to override). But images are not getting picked.

Does background-image attribute have any problem with such
overriding??

Thanks a lot,
Nilesh Dhakras


"Martin Dechev" <de*******@hotm ail.com> wrote in message news:<#j******* *******@tk2msft ngp13.phx.gbl>. ..
Well, it's mentioned in the CSS1 specifications:

http://www.w3.org/TR/REC-CSS1.html#url

Quote:
Partial URLs are interpreted relative to the source of the style sheet, not
relative to the document

Greetings
Martin
"Jiho Han" <ji******@infin ityinfo.com> wrote in message
news:eb******** ******@TK2MSFTN GP12.phx.gbl...
It's been my experience that the url property is always relative to the

page
not the stylesheet.
I've checked both MSDN and W3C spec but they don't seem to discuss about

the
url attribute in detail.

Jiho

"Martin Dechev" <de*******@hotm ail.com> wrote in message
news:uk******** ******@TK2MSFTN GP09.phx.gbl...
Hi, Nilesh Dhakras,

The paths should be relative to the .css file. Are you sure you are not
seeing a cached version of the .css (the one cached in the browser)? Try to hit Ctrl+F5 to force the browser to request everything.

Also, make sure you don't have any error in the css style - if there is an error you will not be shown any error messages, simply there will be no
styles applied to the control.

Hope this helps
Martin
"Nilesh" <dh*******@hotm ail.com> wrote in message
news:ae******** *************** ***@posting.goo gle.com...
> I am using background-image attribute in a CSS file and linking the
> CSS file to aspx page. But strangly, background-image attribute is not
> working for relative URL.
>
> e.g. If I apply following css
> .navbar-background {
> background-image: url(images/menubar.gif);
> }
>
> the image is not appearing on the page. It seems that IE is picking
> the image path relative to aspx file (instead of CSS file!)
>
> If i change the CSS to
> .navbar-background {
> background-image: url(http:\\myse rver\cp\images\ menubar.gif);
> }
> then it's working.
> What is the problem here?? Can someone please explain?
> [Note: I am using IE6]
>
> regards,
> Nilesh Dhakras.


Nov 18 '05 #7
Hi, Nilesh,

You can import the "base" stylesheet in the "custom" like this:

@import url(../styles/base.css);

and then you will be guaranteed to override the class definitions of the
"base" css.

Another thing you can try is to set the background-image as "! important" in
the "custom" css:

..navbar-background {
background-image: url(images/menubar.gif) ! important;
}

but I haven't try this myself. The first method is the official
recommendation for overriding.

Hope this helps
Martin
"Nilesh" <dh*******@hotm ail.com> wrote in message
news:ae******** *************** ***@posting.goo gle.com...
Hi Martin,

Thanks a lot for your inputs. But I am really facing strange behavior.

I have a base CSS which is having this class
.navbar-background {
background-image: url(images/menubar.gif);
}
The base CSS is working just as expected (and as you explained). The
images are getting picted relative to the CSS file's directory (and
not the page's directory).

But when I create another custom CSS, and override this class in that
CSS, then the problem comes. My custom CSS has exactly same class but
with diff path (as it's placed in a diff directory than the base CSS).
In the page's <HEAD> section, I am mentioning the custion CSS after
the base CSS (to override). But images are not getting picked.

Does background-image attribute have any problem with such
overriding??

Thanks a lot,
Nilesh Dhakras


"Martin Dechev" <de*******@hotm ail.com> wrote in message

news:<#j******* *******@tk2msft ngp13.phx.gbl>. ..
Well, it's mentioned in the CSS1 specifications:

http://www.w3.org/TR/REC-CSS1.html#url

Quote:
Partial URLs are interpreted relative to the source of the style sheet, not relative to the document

Greetings
Martin
"Jiho Han" <ji******@infin ityinfo.com> wrote in message
news:eb******** ******@TK2MSFTN GP12.phx.gbl...
It's been my experience that the url property is always relative to the
page
not the stylesheet.
I've checked both MSDN and W3C spec but they don't seem to discuss
about the
url attribute in detail.

Jiho

"Martin Dechev" <de*******@hotm ail.com> wrote in message
news:uk******** ******@TK2MSFTN GP09.phx.gbl...
> Hi, Nilesh Dhakras,
>
> The paths should be relative to the .css file. Are you sure you are
not > seeing a cached version of the .css (the one cached in the browser)? Try to
> hit Ctrl+F5 to force the browser to request everything.
>
> Also, make sure you don't have any error in the css style - if there
is an
> error you will not be shown any error messages, simply there will be

no > styles applied to the control.
>
> Hope this helps
> Martin
> "Nilesh" <dh*******@hotm ail.com> wrote in message
> news:ae******** *************** ***@posting.goo gle.com...
> > I am using background-image attribute in a CSS file and linking the > > CSS file to aspx page. But strangly, background-image attribute is not > > working for relative URL.
> >
> > e.g. If I apply following css
> > .navbar-background {
> > background-image: url(images/menubar.gif);
> > }
> >
> > the image is not appearing on the page. It seems that IE is picking > > the image path relative to aspx file (instead of CSS file!)
> >
> > If i change the CSS to
> > .navbar-background {
> > background-image: url(http:\\myse rver\cp\images\ menubar.gif);
> > }
> > then it's working.
> > What is the problem here?? Can someone please explain?
> > [Note: I am using IE6]
> >
> > regards,
> > Nilesh Dhakras.
>
>

Nov 18 '05 #8

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

Similar topics

5
9499
by: Paul Schnitter | last post by:
Update: My custom control is based on the article "Creating Visual Basic .NET controls from scratch" in "Adventures in .NET" on MSDN. It is designed to be a replacement for the VB6 shape control. My control draws a shape (circle, square, rectangle ...)
12
6728
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"> <span>Abc</span> <span style="background: white; color: black; line-height: 3">Abc</span> <span>Abc</span> </div>
7
5802
by: ryan.fairchild | last post by:
Ok I basically am creating a container for a bunch of other <div> tags. But I want to make four jpegs/gif/whatever that goes in each corner so they look rounded. I thought this is how I would do it but I could be wrong. body { background:#999 url("http://") no-repeat top left; background/* */:/**/url("http://") no-repeat top right; background: /**/url("http://") no-repeat top right;
16
3934
by: J. B. Moreno | last post by:
I read the faq, and it mentions that IE 4 on windows requires setting a printing option to allow background colors to be printed. Things change, life goes on, other browsers come into existence.... So, is there a way in CSS to say "Yeah, print these background colors", without the user having to turn on an option that will then apply to all pages printed? Thanks,
1
11471
by: laredotornado | last post by:
Hello, I was wondering if there is any cross-browser CSS way to specify that I want the background color of a readonly input text field to be the same as its parent row. Right now, I have <tr class="myRowClass"> <td align="right">Account Username</td> <td align="left"> <div id="loginMsg" name="loginMsg"><input
2
2858
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 default transparent. Why does it require that every CSS defined element have their background-color defined? Also, when I set styles in the following way:
7
8300
by: Guliver | last post by:
Hello. I'm configuring the apearence of my forum and I have a question for anyone who can help me. I have a backgroud picture and I would like it to be visible but I'm trying to mantain a background color so the leters are visible too. If i use an alpha filter apllied to the background (td.background{filter:Alpha(Opacity=80);) I'll get the all forum whith an opacity of 80%... If i use an alpha filter apllied to the background color...
11
2193
by: Gérard Talbot | last post by:
Hello, <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <title></title> <style type="text/css"> body {background-color: white; color: black;} #parent_block {background-color: red; width: 100%;} #nested_child_block {margin: 150px 0px; background-color: green; color: white;}
19
3979
by: david.karr | last post by:
If in my CSS I set the "background-color" property on the "body" element, it only covers the background of the elements defined in the body, up to the current width and height of the page. However, if the current component set has a resulting small height, this leaves most of the page with the original background color (white). However, if I set the property on the "html" element instead, it does color the entire visible page, beyond the...
4
2493
by: yawnmoth | last post by:
I'm trying to write a script whereby the body background is changed to back (from white) when the mouse button is held down and kept held down. When you lift it up, I'd like it to change back to white. Unfortunately, I'm not sure how to do that. Any ideas? Here's my code: http://www.frostjedi.com/terra/scripts/demo/onmousedown.html Thanks!
0
8691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8620
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9038
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8920
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7755
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6536
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3060
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2012
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.