mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-12 05:31:41 +00:00
Add a Sass function to convert pixels to rems (resolve #67)
This commit is contained in:
@ -77,10 +77,26 @@ $bold: 700;
|
|||||||
margin-right: 0.35rem;
|
margin-right: 0.35rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FUNCTIONS
|
||||||
|
|
||||||
|
$browser-context: 16;
|
||||||
|
|
||||||
|
@function rem($pixels, $context: $browser-context) {
|
||||||
|
@if (unitless($pixels)) {
|
||||||
|
$pixels: $pixels * 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (unitless($context)) {
|
||||||
|
$context: $context * 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@return $pixels / $context * 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
border-top: 1rem solid red;
|
border-top: 1rem solid red;
|
||||||
font-family: $sans-serif;
|
font-family: $sans-serif;
|
||||||
font-size: 20px;
|
font-size: rem(20);
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user