I have two reasons why I want to use csssprites for submit buttons:
- I have a dynamically created button that can be localized in the future
- I want only 1 HTTP request, even if I have 5 buttons on the page
The problem is that I want to avoid javascript for buttons, so I need to use an input field of type image . I can set the background image in this field as well as for any csssprite.
The problem is that I found that I need to set the image source to an empty pixel, otherwise I get an icon with a damaged image.
With that said, this is the best solution I've come across:
<style> .csssprite_cat { background-image:url(http://www.mrfreefree.com/images/speciali/211/funny_cat_50.jpg); width: 50px; height: 50px; } </style> <input type=image src="http://www.grasse-ac.com/gif/no_pixel.gif" class="csssprite_cat"> <input type=image class="csssprite_cat">
(You can simply download this file directly to the browser - I borrow images from a random site).
This works fine, but I have to use our old old friend pixel.gif . Very nostalgic!
There is probably no better way without javascript if in css there is no way to hide the text and icon of the broken image.
html css css-sprites
Simon_Weaver
source share