This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 61082
    
  66

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]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Adjusting location of images in a CSS file using url() ?