Skip to content

Instantly share code, notes, and snippets.

@jeroentbt
Created June 8, 2013 20:27
Show Gist options
  • Save jeroentbt/5736456 to your computer and use it in GitHub Desktop.
Save jeroentbt/5736456 to your computer and use it in GitHub Desktop.
CSS Image replacement
$imageWidth: 100px;
$imageHeight: 30px;
.replace {
display: block;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: url(http://notrealdomain2.com/newbanner.png) no-repeat;
width: $imageWidth;
height: $imageHeight;
padding-left: $imageWidth;
}
// It works on just about any element, even empty ones like <img> or <hr>
// Browser support is excellent (Chrome, Firefox, Opera, Safari, IE8+) http://caniuse.com/#feat=css3-boxsizing
// Refrains from using SEO unfriendly display: none or other properties
// source: http://css-tricks.com/replace-the-image-in-an-img-with-css/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment