Cannot use images linked from stylesheet on Wamp
Posted by: NickHeyek (---.hsd1.il.comcast.net)
Date: October 15, 2013 03:45AM

Hi, I just started using Wamp and on notepad++, my file had no problem presenting images that I linked. On Wamp however, they just don't appear. They are written right, they just don't show up on local host. Here is my code for them.

html, body

{
background-image: url("file:///C:/Users/Nick/Documents/images/background.jpg"winking smiley;
}

and..

#mid {
background-image: url("file:///C:/Users/Nick/Documents/images/background2.jpg"winking smiley;
}

please help me out here really frustrating

Options: ReplyQuote
Re: Cannot use images linked from stylesheet on Wamp
Posted by: RiggsFolly (---.as13285.net)
Date: October 15, 2013 10:41AM

Well actually they are not written correctly.

I assume you were doubleclicking the file from explorer! That does not use Apache to serve the page and therefore your previous tests were null and void.

Unless you are familiar with virtual hosts, you should have your site code in a folder under c:\wamp\www for example c:\wamp\www\project1.

So you would have this kind of structure

c:\wamp\www\project1 (containing your .php pages)
\project1\images (containng images)
\project1\javascripts (containing any js scripts)
\project1\styles (containing any css scripts)


The proper format for a url used from a css file in the style folder would then be:

html, body {
  background-image: url("/images/background.jpg"winking smiley
}

Remember files addressed from a css file have to be relative to the location of the css file.

And in your HTML/PHP file located in the project1 folder, the urls for example for an img tag would be


  <img src="images/mylittlepicture.jpg"winking smiley
}



In short, dont use explorer to launch your web pages, especially if they contain php script as php scripts will only run if you use the browser to launch the site and therefore Apache which has the knowledge to pass the php parts of a page to the php interpreter. Explorer launched pages do not.

Options: ReplyQuote
Re: Cannot use images linked from stylesheet on Wamp
Posted by: NickHeyek (---.hsd1.il.comcast.net)
Date: October 15, 2013 01:18PM

Yeah I''m completely new at this and I'm trying to teach myself. Thank you so much for your help!

Options: ReplyQuote


Sorry, only registered users may post in this forum.