Last active
August 29, 2015 14:14
-
-
Save certainlyakey/06a8a4f729b7d570371e to your computer and use it in GitHub Desktop.
Line-height based baseline grid SASS mixin, supports rem and px. Displayed above the page content. Press W to toggle
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
@function strip-units($number) { | |
@return $number / ($number * 0 + 1); | |
} | |
// Mixins | |
//requires strip-units function | |
@mixin baseline-grid($baseline, $line-color-01: #ccc, $line-color-02: transparent) { | |
$browser-fz-base:16; | |
@if (unit($baseline) == 'rem') { | |
$baseline:$baseline*$browser-fz-base; | |
} | |
$baseline:strip-units($baseline); | |
.baselinegrided { | |
width:100%; height:100%; position:absolute; top:0; left:0; z-index:10000; display:none; pointer-events:none; | |
background: -webkit-repeating-linear-gradient(180deg, $line-color-02, $line-color-02 $baseline - 1px, $line-color-01 $baseline + px); | |
background: -moz-repeating-linear-gradient(180deg, $line-color-02, $line-color-02 $baseline - 1px, $line-color-01 ($baseline + px)); | |
background: -ms-repeating-linear-gradient(180deg, $line-color-02, $line-color-02 $baseline - 1px, $line-color-01 ($baseline + px)); | |
background: repeating-linear-gradient(180deg, $line-color-02, $line-color-02 $baseline - 1px, $line-color-01 ($baseline + px)); | |
background-size:100% ($baseline + px); | |
} | |
} |
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
//assumes jQuery | |
$(document).ready(function() { | |
$('body').append('<div class="baselinegrided"></div>'); | |
$('.baselinegrided').height($(document).height()); | |
$(document).on('keypress', function(e) { | |
var code = e.keyCode || e.which; | |
if(code === 119) { | |
$('.baselinegrided').toggle(); | |
} | |
}); | |
}); |
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
body {@include baseline-grid($base-line-height);} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment