wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Adjusting location of images in a CSS file using url() ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Adjusting location of images in a CSS file using url() ?" Watch "Adjusting location of images in a CSS file using url() ?" New topic
Author

Adjusting location of images in a CSS file using url() ?

Rajesh Khan
Ranch Hand

Joined: Oct 16, 2011
Posts: 230
I downloaded a feature having CSS and some images. However i rearranged them removed the images from the CSS folder and inserted them in a separate folder placed next to the cSS folder called Images. The file hierarchy looks like this


Initially the code in the css file was like

which made it appear like this in firefox console
http://localhost:8080/Project/CSS/menubg.gif [HTTP/1.1 404 Not Found 3ms]

How can i adjust the above CSS coed so it looks like the following
http://localhost:8080/Project/Images/menubg.gif

Suggestion??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60740
    
  65

You just need to adjust the URLs in the CSS file to address the images. Because CSS files aren't active (so you can't dynamically use the context path), generally page relative URLs are used. E.g. '../../Images/whatever.gif'.

P.S. I highly recommend using only lowercase for folder names.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Adjusting location of images in a CSS file using url() ?
 
Similar Threads
Where to store css and js files in eclipse
problem with server relative paths for images
web.xml url-pattern wildcard not working in Tomcat6
Having a hard time getting my servlet to be available
Tomcat, JSP and Applet