472,365 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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:\\myserver\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 5040
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*******@hotmail.com> wrote in message
news:ae**************************@posting.google.c om...
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:\\myserver\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*******@hotmail.com> wrote in message
news:ae**************************@posting.google.c om...
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:\\myserver\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*******@hotmail.com> wrote in message
news:uk**************@TK2MSFTNGP09.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*******@hotmail.com> wrote in message
news:ae**************************@posting.google.c om...
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:\\myserver\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******@infinityinfo.com> wrote in message
news:eb**************@TK2MSFTNGP12.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*******@hotmail.com> wrote in message
news:uk**************@TK2MSFTNGP09.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*******@hotmail.com> wrote in message
news:ae**************************@posting.google.c om...
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:\\myserver\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*******@hotmail.com> wrote in messag
news:ae**************************@posting.google.c om..
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:\\myserver\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*******@hotmail.com> wrote in message news:<#j**************@tk2msftngp13.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******@infinityinfo.com> wrote in message
news:eb**************@TK2MSFTNGP12.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*******@hotmail.com> wrote in message
news:uk**************@TK2MSFTNGP09.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*******@hotmail.com> wrote in message
news:ae**************************@posting.google.c om...
> 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:\\myserver\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*******@hotmail.com> wrote in message
news:ae**************************@posting.google.c om...
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*******@hotmail.com> wrote in message

news:<#j**************@tk2msftngp13.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******@infinityinfo.com> wrote in message
news:eb**************@TK2MSFTNGP12.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*******@hotmail.com> wrote in message
news:uk**************@TK2MSFTNGP09.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*******@hotmail.com> wrote in message
> news:ae**************************@posting.google.c om...
> > 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:\\myserver\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
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...
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">...
7
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...
16
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...
1
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 ...
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...
7
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...
11
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;}...
19
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,...
4
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...

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.