aspose file tools
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
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply 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: 224
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 opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
 
subject: Adjusting location of images in a CSS file using url() ?
 
Threads others viewed
Tomcat, JSP and Applet
web.xml url-pattern wildcard not working in Tomcat6
Having a hard time getting my servlet to be available
Where to store css and js files in eclipse
problem with server relative paths for images
IntelliJ Java IDE