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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 60048
    
  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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adjusting location of images in a CSS file using url() ?
 
Similar Threads
Having a hard time getting my servlet to be available
Tomcat, JSP and Applet
web.xml url-pattern wildcard not working in Tomcat6
Where to store css and js files in eclipse
problem with server relative paths for images