473,748 Members | 2,690 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 5127
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
9504
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
6736
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
5804
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
3937
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
11477
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
2863
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
8302
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
2203
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
3987
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
2496
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
8995
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
8832
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
9561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9381
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
9332
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
9254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2217
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.