Skip to content

Instantly share code, notes, and snippets.

@mgrandrath
Last active December 15, 2015 00:59
Show Gist options
  • Save mgrandrath/5176410 to your computer and use it in GitHub Desktop.
Save mgrandrath/5176410 to your computer and use it in GitHub Desktop.
Silent classes for pseudo elements as icon containers
.foo, .bar {
position: relative;
}
.foo:before, .bar:after {
position: absolute;
content: "";
display: block;
}
.foo:before {
width: 10px;
height: 10px;
top: 10px;
left: 10px;
background-image: url(foo.png);
}
.bar:after {
width: 20px;
height: 20px;
top: 20px;
right: 20px;
background-image: url(bar.png);
}
%pseudo-icon-container {
position: relative;
}
%pseudo-icon {
position: absolute;
content: "";
display: block;
}
%pseudo-icon-before {
@extend %pseudo-icon-container;
&:before {
@extend %pseudo-icon;
}
}
%pseudo-icon-after {
@extend %pseudo-icon-container;
&:after {
@extend %pseudo-icon;
}
}
.foo {
@extend %pseudo-icon-before;
&:before {
width: 10px;
height: 10px;
top: 10px;
left: 10px;
background-image: url(foo.png);
}
}
.bar {
@extend %pseudo-icon-after;
&:after {
width: 20px;
height: 20px;
top: 20px;
right: 20px;
background-image: url(bar.png);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment