Created
July 24, 2015 10:04
-
-
Save sushicodeur/64d607231ff47741abb8 to your computer and use it in GitHub Desktop.
SCSS Image Ratio
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
@function pxtoem($target, $context:16px) { | |
@return ($target / $context) + 0em; | |
} | |
.entry-attachment { // Image ratio 135x180 | |
$w: 135px; | |
$h: 180px; | |
$ratio: 100/($w/$h); | |
padding-top: $ratio; | |
display: block; | |
overflow: hidden; | |
position: relative; | |
width: pxtoem($w); | |
height: pxtoem($h); | |
background: url(images/logo.png) center center no-repeat; // Placeholder if no image | |
background-size: 50%; | |
img { | |
display: block; | |
min-width: 100%; | |
min-height: 100%; | |
position: absolute; | |
top: 0; | |
bottom: 0; | |
left: 0; | |
right: 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment