I think the basis of this is to add dynamic functionality to CSS. I donβt know about if / else checking in CSS other than detecting browsers, however this is what I would do if I ever need to do something like this.
If you are using php you can do this:
$imagename = "image.png"; if (file_exists($imagename)){ echo '<p class="exists">'; } else { echo '<p class="dne">'; }
Then in css you can have
.exists{background:url("../img/git-sprite.png") no-repeat 0px -32px;} .dne{background:url("../img/git-sprite2.png") no-repeat 0px -32px;}
This way you can add if / else functionality for this in the CSS itself. You do not need to use PHP, I'm sure javascript will work as well
raghav.mohan
source share