I have this line in my CSS:
.ui-icon-zoom-in { content: url(images/16x16/ZoomIn.png); }
Which I am using with jQuery UI Button widget li
One can use the box-sizing
property to keep the dimensions, addind the new image as background image and pushing "out" the existing (old) inline-image by padding-left
:
.image{
-moz-box-sizing: border-box;
box-sizing: border-box;
background: url(https://yourdomain/yoursite/yourasset.png) no-repeat;
width: 20px; /* Width of new image */
height: 25px; /* Height of new image */
padding-left: 20px; /* Equal to width of new image */
}
box-sizing
has a good webbrowser-support: https://caniuse.com/#feat=css3-boxsizing
Adopted from: https://css-tricks.com/replace-the-image-in-an-img-with-css/