Last active
July 13, 2017 09:56
-
-
Save pierreburel/f75f0ffd0910a99eee77 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains 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
> 1% | |
last 2 versions |
This file contains 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
<h1>Test</h1> |
This file contains 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
// ---- | |
// libsass (v3.5.0.beta.2) | |
// ---- | |
$rem-baseline: 16px !default; | |
$rem-fallback: false !default; | |
$rem-px-only: false !default; | |
@function rem-separator($list, $separator: false) { | |
@if $separator == "comma" or $separator == "space" { | |
@return append($list, null, $separator); | |
} | |
@if function-exists("list-separator") == true { | |
@return list-separator($list); | |
} | |
// list-separator polyfill by Hugo Giraudel (https://sass-compatibility.github.io/#list_separator_function) | |
$test-list: (); | |
@each $item in $list { | |
$test-list: append($test-list, $item, space); | |
} | |
@return if($test-list == $list, space, comma); | |
} | |
@mixin rem-baseline($zoom: 100%) { | |
font-size: $zoom / 16px * $rem-baseline; | |
} | |
@function rem-convert($to, $values...) { | |
$result: (); | |
$separator: rem-separator($values); | |
@each $value in $values { | |
@if type-of($value) == "number" and unit($value) == "rem" and $to == "px" { | |
$result: append($result, $value / 1rem * $rem-baseline + 0px, $separator); | |
} @else if type-of($value) == "number" and unit($value) == "px" and $to == "rem" { | |
$result: append($result, $value / $rem-baseline + 0rem, $separator); | |
} @else if type-of($value) == "list" { | |
$value-separator: rem-separator($value); | |
$value: rem-convert($to, $value...); | |
$value: rem-separator($value, $value-separator); | |
$result: append($result, $value, $separator); | |
} @else { | |
$result: append($result, $value, $separator); | |
} | |
} | |
@return if(length($result) == 1, nth($result, 1), $result); | |
} | |
@function rem($values...) { | |
@if $rem-px-only { | |
@return rem-convert(px, $values...); | |
} @else { | |
@return rem-convert(rem, $values...); | |
} | |
} | |
@mixin rem($properties, $values...) { | |
@if type-of($properties) == "map" { | |
@each $property in map-keys($properties) { | |
@include rem($property, map-get($properties, $property)); | |
} | |
} @else { | |
@each $property in $properties { | |
@if $rem-fallback or $rem-px-only { | |
#{$property}: rem-convert(px, $values...); | |
} | |
@if not $rem-px-only { | |
#{$property}: rem-convert(rem, $values...); | |
} | |
} | |
} | |
} | |
.demo { | |
font-size: rem(24px); // Simple | |
padding: rem(5px 10px); // Multiple values | |
border-bottom: rem(1px solid black); // Multiple mixed values | |
box-shadow: rem(0 0 2px #ccc, inset 0 0 5px #eee); // Comma-separated values | |
text-shadow: rem(1px 1px) #eee, rem(-1px) 0 #eee; // Alternate use | |
} |
This file contains 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
.demo { | |
font-size: 1.5rem; | |
padding: 0.3125rem 0.625rem; | |
border-bottom: 0.0625rem solid black; | |
box-shadow: 0 0 0.125rem #ccc, inset 0 0 0.3125rem #eee; | |
text-shadow: 0.0625rem 0.0625rem #eee, -0.0625rem 0 #eee; | |
} |
This file contains 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="demo">Test</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment