The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> stylesheet linking to images no working
codin
post May 18 2012, 02:16 AM
Post #1





Group: Members
Posts: 6
Joined: 12-May 12
Member No.: 17,102



hello,
I have created a html page in which I am using image sprites and other images for backgrounds etc..
I created a div element which has a background.
I styled the div element in a separate stylesheet which has the background image specified and many other styles specified.
but when opening the page, there is no background visible..

I have checked stylesheet links and image links are all right.
other styles such as fonts margin etc etc are getting applied from the stylesheet.


my file locations are ;

Web project <---- main content folder (contains images and styles folder and the main index.html)
Images <---- image folder
Styles <----- stylesheet folder

If the link to background is applied inline, it works, but i need to use it from the stylesheet..

and if the complete link is given i.e.. starting from the hard drive path it works..
Pls help.

This post has been edited by codin: May 18 2012, 02:30 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Frederiek
post May 18 2012, 02:54 AM
Post #2


Programming Fanatic
********

Group: Members
Posts: 5,146
Joined: 23-August 06
From: Europe
Member No.: 9



The paths of images inside the CSS should be different from the paths of inline images inside your HTML. The paths in the CSS need to be relative to the stylesheet, not the HTML.

In your case, in CSS that would be e.g.:
background: url(../Images/image_name.png) ...;

while in HTML it would be:
<img src="Images/image_name.png" ...>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
codin
post May 19 2012, 03:10 AM
Post #3





Group: Members
Posts: 6
Joined: 12-May 12
Member No.: 17,102



QUOTE(Frederiek @ May 18 2012, 02:54 AM) *

The paths of images inside the CSS should be different from the paths of inline images inside your HTML. The paths in the CSS need to be relative to the stylesheet, not the HTML.

In your case, in CSS that would be e.g.:
background: url(../Images/image_name.png) ...;

while in HTML it would be:
<img src="Images/image_name.png" ...>



Oh ok... yes thank you .. its working like that now...
thanks again
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Frederiek
post May 19 2012, 06:59 AM
Post #4


Programming Fanatic
********

Group: Members
Posts: 5,146
Joined: 23-August 06
From: Europe
Member No.: 9



You're welcome.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 18th April 2024 - 09:44 AM