Created
October 30, 2017 17:57
-
-
Save akfzambrana/8031e4257bf4b7e656ceb929406ea970 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
// ---- | |
// Sass (v3.4.21) | |
// Compass (v1.0.3) | |
// ---- | |
$font-size-base: 16px !default; | |
$view-width-base: 1024px !default; | |
@function _clean-unit($value) { | |
@if type-of($value) == 'number' { | |
@return $value / ($value * 0 + 1); | |
} @else { | |
@warn "#{$value} nao e um numero"; | |
} | |
} | |
@function _decimal-floor($number, $digits: 0) { | |
$n: 1; | |
$result: null; | |
$number: _clean-unit($number); | |
@if type-of($number) != number { | |
@warn '#{$number} is not a number.'; | |
@return $result; | |
} | |
@if type-of($digits) != number { | |
@warn '#{$digits} is not a number.'; | |
@return $result; | |
} | |
@if $digits > 0 { | |
@for $i from 1 through $digits { | |
$n: $n * 10; | |
} | |
} | |
$result: floor($number * $n) / $n; | |
@return $result; | |
} | |
@function vw($value) { | |
@if type-of($value) == 'number' { | |
$value: _clean-unit($value); | |
$view-width: _clean-unit($view-width-base); | |
$convertion: _decimal-floor(($value * 100) / $view-width, 2); | |
@return $convertion * 1vw; | |
} @else { | |
@warn '#{$value} nao e um numero'; | |
} | |
} | |
.class { | |
width: vw(300); | |
} | |
.class2 { | |
width: vw(300px); | |
} |
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
.class { | |
width: 29.29vw; | |
} | |
.class2 { | |
width: 29.29vw; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment