Last active
August 29, 2015 14:11
-
-
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="square"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.square { | |
.diamond-inside-square(280px, 'http://fillmurray.com/g/420/420'); | |
} |
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
Here is a very Bill Murray example. 😃
