Skip to content

Instantly share code, notes, and snippets.

@shengt
Created February 27, 2014 21:18
Show Gist options
  • Save shengt/9259780 to your computer and use it in GitHub Desktop.
Save shengt/9259780 to your computer and use it in GitHub Desktop.
Some useful mixins for stylus
//
// Mixins
// --------------------------------------------------
// Font face
font-url(file)
return url(file)
webfont(family, file, weight = normal, style = normal)
@font-face
font-family family
src font-url(file + '.eot')
src font-url(file + '.eot?#iefix') format('embedded-opentype'),
font-url(file + '.woff') format('woff'),
font-url(file + '.ttf') format('truetype'),
font-url(file + '.svg#'+ family) format('svg')
font-weight weight
font-style style
// Font
font-size(size)
if unit(size) is 'px'
font-size size
font-size (remove-unit(size) / 10)rem
else if unit(size) is 'pt'
font-size (remove-unit(size) * 4 / 3)px
font-size (remove-unit(size) * 4 / 30)rem
else
font-size size
line-height(height)
if unit(height) is 'px'
line-height height
line-height (remove-unit(height) / 10)rem
else if unit(height) is 'pt'
line-height (remove-unit(height) * 4 / 3)px
line-height (remove-unit(height) * 4 / 30)rem
else
line-height height
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment