Skip to content

Instantly share code, notes, and snippets.

@rymizuki
Created August 6, 2014 05:38
Show Gist options
  • Save rymizuki/f38c3d132f74cdeef7a0 to your computer and use it in GitHub Desktop.
Save rymizuki/f38c3d132f74cdeef7a0 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div class="block">
hello
</div>
<div class="block2">
hello
</div>
// ----
// Sass (v3.3.14)
// Compass (v1.0.0.rc.1)
// ----
@mixin image-replacement(
$color: transparent,
$repeat: no-repeat,
$position: center center,
$path: null,
$size: 0 0
) {
width: auto;
height: auto;
font: 0/0 a;
line-height: 0;
text-shadow: none;
color: transparent;
&:after {
content: '';
display: block;
@if $path != null {
background: $color url($path) $repeat $position;
background-size: $size;
}
@else {
@content
}
}
}
.block2 {
@include image-replacement(
$path: "/path/to.png"
)
}
.block {
@include image-replacement {
background: red;
width: 100px;
height: 100px;
}
}
.block2 {
width: auto;
height: auto;
font: 0/0 a;
line-height: 0;
text-shadow: none;
color: transparent;
}
.block2:after {
content: '';
display: block;
background: transparent url("/path/to.png") no-repeat center center;
background-size: 0 0;
}
.block {
width: auto;
height: auto;
font: 0/0 a;
line-height: 0;
text-shadow: none;
color: transparent;
}
.block:after {
content: '';
display: block;
background: red;
width: 100px;
height: 100px;
}
<div class="block">
hello
</div>
<div class="block2">
hello
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment