Is it possible to use SVG images as CSS background?

I was reading, "Use CSS Images instead of IMG tag: An easy way to..

  • speed up the rendering of an image is to simply call as a background of a div tag.", and elsewhere I read that that if you use CSS for images the images will come up last (after your text), which is what I want. But I don't want to load up my css page with a long list of images (40), becuase the CSS page is loaded into the visitor's browser, and so will slow the length of time it takes to bring up my site. I really don't want to use sprites. Isn't there a way where I can load the images into a PHP includes file and refer to the includes file in the CSS, but what code would I use in the main coding (HTML) from page to page to bring up the different images for different pages? Thanks for the help

  • Answer:

    You could pass a parameter in your URLs query string, like: mypage.php?img=1 Then you can name your CSS file something like: style.css.php In your CSS file you can do something like: $img = $_GET['img']; If ($img > 0 && $img < 5) { print "#myDiv { background-url: image1.jpg }"; } else { print "#myDiv { background-url: image2.jpg }"; } Or you know, use whatever argument you want within your if statement.

Lisa at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.