Skip to content

Instantly share code, notes, and snippets.

@yankeyhotel
Last active August 29, 2015 14:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yankeyhotel/3685dd16438123a75153 to your computer and use it in GitHub Desktop.
Save yankeyhotel/3685dd16438123a75153 to your computer and use it in GitHub Desktop.
A LESS Mixin to mask a square image into a diamond shape (aka 45deg square).
.diamond-inside-square (@square: 100px; @background-img) {
.square(@square);
.rotate(-45deg);
margin: @square/4;
overflow: hidden;
&:after {
.square(@square*1.5);
.rotate(45deg);
background: url(@background-img);
display: block;
content: '';
margin: -(@square/4);
}
}
<div class="square"></div>
.square {
.diamond-inside-square(280px, 'http://fillmurray.com/g/420/420');
}
@yankeyhotel
Copy link
Author

Here is a very Bill Murray example. 😃
image

@yankeyhotel
Copy link
Author

Also I am using this in the context of Bootstrap, so .square() and .rotate() are native mixins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment