Last active
January 25, 2025 17:53
-
-
Save BenMorel/e9e34c08360ebbbd0634 to your computer and use it in GitHub Desktop.
Revisions
-
BenMorel revised this gist
Sep 17, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,9 +3,11 @@ * Fix for vw, vh, vmin, vmax on iOS 7. * http://caniuse.com/#feat=viewport-units * * This fix works by replacing viewport units with px values on known screen sizes. * * iPhone 6 and 6 Plus cannot run iOS 7, so are not targeted by this fix. * Target devices running iOS 8+ will incidentally execute the media query, * but this will still produce the expected result; so this is not a problem. * * As an example, replace: * -
BenMorel revised this gist
Sep 17, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ * http://caniuse.com/#feat=viewport-units * * iPhone 6 and 6 Plus cannot run iOS 7, so are not targeted by this fix. * Target devices running iOS 8+ will incidentally execute the media query, * but this will still produce the expected result. * * As an example, replace: -
BenMorel revised this gist
Sep 17, 2015 . 1 changed file with 11 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,21 @@ /** * Fix for vw, vh, vmin, vmax on iOS 7. * http://caniuse.com/#feat=viewport-units * * iPhone 6 and 6 Plus cannot run iOS 7, so are not targeted by this fix. * Targeted devices running iOS 8+ will incidentally execute the media query, * but this will still produce the expected result. * * As an example, replace: * * height: 50vh; * font-size: 5vmin; * * with: * * @include viewport-unit(height, 50vh); * @include viewport-unit(font-size, 5vmin); */ @mixin viewport-unit($property, $value) { #{$property}: $value; @@ -21,10 +25,8 @@ @if (index((vw, vh, vmin, vmax), $unit) != null) { $devices: ( (768px, 1024px), // iPad (all versions) (320px, 480px), // iPhone 4 (320px, 568px) // iPhone 5, 5C, 5S ); @each $device in $devices { -
BenMorel revised this gist
Sep 17, 2015 . 1 changed file with 38 additions and 31 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,39 +14,46 @@ * @include viewport-unit(font-size, 5vh); */ @mixin viewport-unit($property, $value) { #{$property}: $value; $unit: unit($value); @if (index((vw, vh, vmin, vmax), $unit) != null) { $devices: ( (768px, 1024px), // iPad (all versions) (320px, 480px), // iPhone 4 and before (320px, 568px), // iPhone 5, 5C, 5S (375px, 667px), // iPhone 6 (414px, 736px), // iPhone 6 Plus ); @each $device in $devices { $device-width: nth($device, 1); $device-height: nth($device, 2); $device-query: "only screen and (-webkit-min-device-pixel-ratio: 1)"; $device-query: "#{$device-query} and (device-width: #{$device-width})"; $device-query: "#{$device-query} and (device-height: #{$device-height})"; $percent: $value / ($value * 0 + 1); // see https://github.com/sass/sass/issues/533 $percent-width: $device-width * $percent / 100; $percent-height: $device-height * $percent / 100; @if ($unit == vmin or $unit == vmax) { @media #{$device-query} { #{$property}: if($unit == vmin, $percent-width, $percent-height); } } @else { @media #{$device-query} and (orientation: portrait) { #{$property}: if($unit == vw, $percent-width, $percent-height); } @media #{$device-query} and (orientation: landscape) { #{$property}: if($unit == vw, $percent-height, $percent-width); } } } } } -
BenMorel revised this gist
Sep 17, 2015 . No changes.There are no files selected for viewing
-
BenMorel revised this gist
Sep 17, 2015 . No changes.There are no files selected for viewing
-
BenMorel revised this gist
Sep 17, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ * @include viewport-unit(font-size, 5vh); */ @mixin viewport-unit($property, $value) { @if (unit($value) != 'vw' and unit($value) != 'vh') { @error "Only vw and vh units are supported"; } -
BenMorel revised this gist
Sep 17, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ * @include viewport-unit(font-size, 5vh); */ @mixin viewport-unit($property, $value) { @if (unitless($value) or unit($value) != 'vw' and unit($value) != 'vh') { @error "Only vw and vh units are supported"; } -
BenMorel revised this gist
Sep 17, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ * @include viewport-unit(font-size, 5vh); */ @mixin viewport-unit($property, $value) { @if (unit($value) != 'vw' and unit($value) != 'vh') { @error "Only vw and vh units are supported"; } -
BenMorel revised this gist
Sep 17, 2015 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -31,22 +31,22 @@ #{$property}: $value; @each $device in $devices { $device-width: nth($device, 1); $device-height: nth($device, 2); $device-query: "only screen and (-webkit-min-device-pixel-ratio: 1)"; $device-query: "#{$device-query} and (device-width: #{$device-width})"; $device-query: "#{$device-query} and (device-height: #{$device-height})"; $percent-width: $device-width * $percent / 100; $percent-height: $device-height * $percent / 100; @media #{$device-query} and (orientation: portrait) { #{$property}: if(unit($value) == 'vw', $percent-width, $percent-height); } @media #{$device-query} and (orientation: landscape) { #{$property}: if(unit($value) == 'vw', $percent-height, $percent-width); } } } -
BenMorel revised this gist
Sep 17, 2015 . 1 changed file with 6 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -37,19 +37,15 @@ $percentWidth: $deviceWidth * $percent / 100; $percentHeight: $deviceHeight * $percent / 100; $device-query: "only screen and (-webkit-min-device-pixel-ratio: 1)"; $device-query: "#{$device-query} and (device-width: #{$deviceWidth})"; $device-query: "#{$device-query} and (device-height: #{$deviceHeight})"; @media #{$device-query} and (orientation: portrait) { #{$property}: if(unit($value) == 'vw', $percentWidth, $percentHeight); } @media #{$device-query} and (orientation: landscape) { #{$property}: if(unit($value) == 'vw', $percentHeight, $percentWidth); } } -
BenMorel revised this gist
Sep 17, 2015 . No changes.There are no files selected for viewing
-
BenMorel revised this gist
Sep 17, 2015 . 1 changed file with 18 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,9 +3,15 @@ * Support for vw and vh on buggy iOS Safari. * http://caniuse.com/#feat=viewport-units * * For example, replace: * * height: 50vh; * font-size: 5vh; * * With: * * @include viewport-unit(height, 50vh); * @include viewport-unit(font-size, 5vh); */ @mixin viewport-unit($property, $value) { @if (unitless($value) or unit($value) != 'vw' and unit($value) != 'vh') { @@ -31,11 +37,19 @@ $percentWidth: $deviceWidth * $percent / 100; $percentHeight: $deviceHeight * $percent / 100; @media only screen and (device-width: $deviceWidth) and (device-height: $deviceHeight) and (orientation: portrait) and (-webkit-min-device-pixel-ratio: 1) { #{$property}: if(unit($value) == 'vw', $percentWidth, $percentHeight); } @media only screen and (device-width: $deviceWidth) and (device-height: $deviceHeight) and (orientation: landscape) and (-webkit-min-device-pixel-ratio: 1) { #{$property}: if(unit($value) == 'vw', $percentHeight, $percentWidth); } } -
BenMorel revised this gist
Sep 17, 2015 . 1 changed file with 24 additions and 32 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,48 +3,40 @@ * Support for vw and vh on buggy iOS Safari. * http://caniuse.com/#feat=viewport-units * * Example: replace "height: 50vh;" with "@include viewport-unit(height, 50vh);". * * Note that this can also target non-iOS devices, but will still produce the expected result. */ @mixin viewport-unit($property, $value) { @if (unitless($value) or unit($value) != 'vw' and unit($value) != 'vh') { @error "Only vw and vh units are supported"; } $devices: ( (768px, 1024px), // iPad (all versions) (320px, 480px), // iPhone 4 and before (320px, 568px), // iPhone 5, 5C, 5S (375px, 667px), // iPhone 6 (414px, 736px), // iPhone 6 Plus ); $percent: $value / ($value * 0 + 1); // see https://github.com/sass/sass/issues/533 #{$property}: $value; @each $device in $devices { $deviceWidth: nth($device, 1); $deviceHeight: nth($device, 2); $percentWidth: $deviceWidth * $percent / 100; $percentHeight: $deviceHeight * $percent / 100; @media only screen and (device-width: $deviceWidth) and (device-height: $deviceHeight) and (orientation: portrait) { #{$property}: if(unit($value) == 'vw', $percentWidth, $percentHeight); } @media only screen and (device-width: $deviceWidth) and (device-height: $deviceHeight) and (orientation: landscape) { #{$property}: if(unit($value) == 'vw', $percentHeight, $percentWidth); } } } -
BenMorel revised this gist
Sep 17, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ * Support for vw and vh on buggy iOS Safari. * http://caniuse.com/#feat=viewport-units * * Example: replace "height: 50vh;" with "@include vh(50);". * * Note that this can also target non-iOS devices, but will still produce the expected result. */ -
BenMorel revised this gist
Sep 17, 2015 . No changes.There are no files selected for viewing
-
BenMorel revised this gist
Sep 15, 2015 . No changes.There are no files selected for viewing
-
BenMorel revised this gist
Sep 15, 2015 . No changes.There are no files selected for viewing
-
BenMorel created this gist
Sep 15, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ /** * Support for vw and vh on buggy iOS Safari. * http://caniuse.com/#feat=viewport-units * * Example: replace "width: 50vh;" with "@include vh(50);". * * Note that this can also target non-iOS devices, but will still produce the expected result. */ $devices: ( (768px, 1024px), // iPad (all versions) (320px, 480px), // iPhone 4 and before (320px, 568px), // iPhone 5, 5C, 5S (375px, 667px), // iPhone 6 (414px, 736px), // iPhone 6 Plus ); @mixin vw($percent) { width: #{$percent}vw; @each $device in $devices { $width: nth($device, 1); $height: nth($device, 2); @media only screen and (device-width: $width) and (device-height: $height) and (orientation: portrait) { width: ($width * $percent / 100); } @media only screen and (device-width: $width) and (device-height: $height) and (orientation: landscape) { width: ($height * $percent / 100); } } } @mixin vh($percent) { height: #{$percent}vh; @each $device in $devices { $width: nth($device, 1); $height: nth($device, 2); @media only screen and (device-width: $width) and (device-height: $height) and (orientation: portrait) { height: ($height * $percent / 100); } @media only screen and (device-width: $width) and (device-height: $height) and (orientation: landscape) { height: ($width * $percent / 100); } } }