.box {
color: blue;
.button {
color: red;
}
}
Stylus is a CSS pre-processor.
See: stylus-lang.com
.box
color: blue
.button
color: red
Also works! The colon is optional, as well. This is typically the syntax used with Stylus documents.
border-radius(n)
-webkit-border-radius: n
border-radius: n
div
border-radius: 2px
border-radius(2px)
Mixins can be applied in two different ways.
border-radius(n = 2px)
-webkit-border-radius: n
shadow(offset-x, args...)
box-shadow: offset-x args
margin-top: offset-x
#login
shadow: 1px 2px 5px #eee
See: Rest params
shadow(x, y)
x y (y * 1.5) #000
.button
box-shadow: shadow(x: 2, y: 4)
See: Named parameters
royal-blue = #36a
royal-blue ?= #89f
div
color: royal-blue // #36a
?=
will only set a variable if it’s previously unset.
.logo
width: w = 150
margin-left: -(w / 2)
// or
height: 80px
margin-top: -(@height / 2)
See: Property lookup
#888 + 50% // → #c3c3c3 (lighten)
#888 - 50% // → #444 (darken)
#f00 + 50deg // → #ffd500 (hue)
if color == blue
display: block
else if true and true
display: inline
else if 'hey' is not 'bye'
display: flex
else
display: none
Aliases:
== |
is |
!= |
is not |
!= |
isnt |
See: Conditionals
font-size-1 = 10px
font-size-2 = 20px
font-size-3 = 30px
for i in 1..3
.text-{i}
font-size: lookup('font-size-' + i)
0
null
false
''
if val is a 'string'
if val is a 'ident'
if #fff is a 'rgba' // → true
See: Instance check
alpha(#fff) //→ 1
alpha(rgba(0, 0, 0, 0.2)) //→ 0.2
dark(black) //→ true
light(black) //→ false
hue(#0a0) //→ 50deg
saturation(#f00) //→ 100%
lightness(#f00) //→ 50%
luminosity(#f00) //→ 0.2126
hue(#0a0, 0deg)
saturation(#f00, 50%)
lightness(#f00)
lighten(color, 10%)
darken(color, 10%)
saturate(color, 10%)
desaturate(color, 10%)
invert(color)
tint(color, 50%) // mix with white
shade(color, 50%) // mix with black
unquote(string)
See: Built-in functions
width: image-size('tux.png')[0]
height: image-size('tux.png')[1]
Returns the width and height of a given image.
See: image-size
gradient(color)
add-property('background-image', linear-gradient(top, color, darken(color, 20%)))
color
body
background: gradient(red)
See: add-property