body
color white
textarea
input
border 1px solid #eee
.header
.menu
background-color red
Stylus
body {
color: #fff;
}
textarea,
input {
border: 1px solid #eee;
}
.header .menu {
background-color: #f00;
}
CSS
.btn
a.btn
color #a7a7a7
&:hover
color #000
> span
font-size 10px
Stylus
textarea,
input {
color: #a7a7a7;
}
textarea:hover,
input:hover {
color: #000;
}
CSS
.menu
border 2px #f00 solid
.home &
border 2px #000 solid
Stylus
.menu {
border: 2px #f00 solid;
}
.home .menu {
border: 2px #000 solid;
}
CSS
.list
list-style none
&__item
text-decoration underline
Stylus
.list {
list-style: none;
}
.list__item {
text-decoration: underline;
}
CSS
font-size = 1.4em
font = font-size "Open Sans", Arial
primary-color = #ccc
body
font font, sans-serif
color primary-color
Stylus
body {
font: 1.4em "Open Sans", Arial, sans-serif;
color: #ccc;
}
CSS
.logo
position absolute
top 50%
left 50%
width w = 150px
height h = 80px
margin-left -(w / 2)
margin-top -(h / 2)
Using Variables
.logo
position absolute
top 50%
left 50%
width 150px
height 80px
margin-left -(@width / 2)
margin-top -(@height / 2)
Using Property Lookup
position()
z-index 1 unless @z-index
position arguments
.header
z-index 20
position(absolute)
.header-home
position(absolute)
Stylus
.header {
z-index: 20;
position: absolute;
}
.header-home {
z-index: 1;
position: absolute;
}
CSS
flex()
display -ms-flexbox
display -webkit-flex
display flex
.container
flex()
Stylus
.container {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
CSS
placeholder(element)
{element}::-webkit-input-placeholder
{block}
{element}::-moz-placeholder
{block}
{element}:-ms-input-placeholder
{block}
{element}:-moz-placeholder
{block}
+placeholder(input)
color #ccc
font-style italic
Stylus
input::-webkit-input-placeholder {
color: #ccc;
font-style: italic;
}
input::-moz-placeholder {
color: #ccc;
font-style: italic;
}
input:-ms-input-placeholder {
color: #ccc;
font-style: italic;
}
input:-moz-placeholder {
color: #ccc;
font-style: italic;
}
CSS
listItem()
text-decoration underline
list()
list-style none
> li
listItem()
ul
list()
Stylus
ul {
list-style: none;
}
ul > li {
text-decoration: underline;
}
CSS
grid-col(n)
( 100% / 12 ) * n
.sidebar
width grid-col(3)
.article
width grid-col(9)
Stylus
.sidebar {
width: 25%;
}
.article {
width: 75%;
}
CSS
inner-rad(b, p)
b = unit(b, px)
p = unit(p, px)
b - p
.button
padding 15px
border-radius 20px
.button-inner
border-radius inner-rad(@border-radius, 15px)
Stylus
.button {
padding: 15px;
border-radius: 20px;
}
.button .button-inner {
border-radius: 5px;
}
CSS
padd(width, height)
width / 10 height / 10
.container
width 150px
height 100px
padding padd(@width, @height)
Stylus
.container {
width: 150px;
height: 100px;
padding: 15px 10px;
}
CSS
black-friday = false
body
if black-friday is true
color white
background black
else
color black
background white
black-friday = true
body
if black-friday is true
color white
background black
else
color black
background white
body {
color: #000;
background: #fff;
}
Stylus
body {
color: #fff;
background: #000;
}
CSS
CSS
Stylus
flex-justify(val)
-webkit-justify-content val
justify-content val
if val is 'space-around'
-ms-flex-pack distribute
else if val is 'flex-end'
-ms-flex-pack end
else if val is 'space-between'
-ms-flex-pack justify
else
-ms-flex-pack val
.banners
flex-justify(space-around)
.container
flex-justify(space-between)
.footer
flex-justify(center)
Stylus
.banners {
-webkit-justify-content: space-around;
justify-content: space-around;
-ms-flex-pack: distribute;
}
.container {
-webkit-justify-content: space-between;
justify-content: space-between;
-ms-flex-pack: justify;
}
.footer {
-webkit-justify-content: center;
justify-content: center;
-ms-flex-pack: center;
}
CSS
/* Darken */
.sidebar
background-color darken(red, 10%)
/* Lighten */
.container
background-color lighten(blue, 80%)
/* RGBA */
.footer
background-color rgba(white, .5)
Stylus
/* Darken */
.sidebar {
background-color: #e60000;
}
/* Lighten */
.container {
background-color: #ccf;
}
/* RGBA */
.footer {
background-color: rgba(255,255,255,0.5);
}
CSS
for i in range(0px, 50px, 5)
.p-t-{i}
padding-top: i
Stylus
.p-t-0 {
padding-top: 0px;
}
.p-t-5 {
padding-top: 5px;
}
.p-t-10 {
padding-top: 10px;
}
.p-t-15 {
padding-top: 15px;
}
...
CSS
+prefix-classes('col-')
.xs-1
.xs-2
.xs-3
.xs-4
.xs-5
.xs-6
.xs-7
.xs-8
.xs-9
.xs-10
.xs-11
.xs-12
display inline-block
Stylus
.col-xs-1,
.col-xs-2,
.col-xs-3,
.col-xs-4,
.col-xs-5,
.col-xs-6,
.col-xs-7,
.col-xs-8,
.col-xs-9,
.col-xs-10,
.col-xs-11,
.col-xs-12 {
display: inline-block;
}
CSS
+prefix-classes('col-')
for num in 1..12
.xs-{num}
.md-{num}
.sm-{num}
.lg-{num}
width ( 100% / 12 ) * num
Stylus
.col-xs-1,
.col-md-1,
.col-sm-1,
.col-lg-1 {
width: 8.333333333333334%;
}
.col-xs-2,
.col-md-2,
.col-sm-2,
.col-lg-2 {
width: 16.666666666666668%;
}
...
CSS
flex-basis(val)
-moz-flex-basis val
-webkit-flex-basis val
flex-basis val
for num in 1..12
.col-xs-{num}
flex-basis(( 100% / 12 ) * num)
Stylus
.col-xs-1 {
-moz-flex-basis: 8.333333333333334%;
-webkit-flex-basis: 8.333333333333334%;
flex-basis: 8.333333333333334%;
}
.col-xs-2 {
-moz-flex-basis: 16.666666666666668%;
-webkit-flex-basis: 16.666666666666668%;
flex-basis: 16.666666666666668%;
}
.col-xs-3 {
-moz-flex-basis: 25%;
-webkit-flex-basis: 25%;
flex-basis: 25%;
}
...
CSS
icon-classes = fb-icon insta-icon twitter-icon
icons(className)
li.{className}
background-image url(className'.png')
ul.icons
for num in 0..length(icon-classes) - 1
icons(icon-classes[num])
Stylus
ul.icons li.fb-icon {
background-image: url("fb-icon.png");
}
ul.icons li.insta-icon {
background-image: url("insta-icon.png");
}
ul.icons li.twitter-icon {
background-image: url("twitter-icon.png");
}
CSS
.alert
display inline-block
border-radius 3px
padding 5px
color #fff
background-color blue
.alert-success
@extend .alert
background-color green
.alert-danger
@extend .alert
color #fff
background-color red
Stylus
.alert,
.alert-success,
.alert-danger {
display: inline-block;
border-radius: 3px;
padding: 5px;
color: #fff;
background-color: #00f;
}
.alert-success {
background-color: #008000;
}
.alert-danger {
color: #fff;
background-color: #f00;
}
CSS
/* IMPORT */
@import mixins
@require functions
Stylus
/* IMPORT */
body {
font: 1.4em "Open Sans", Arial, sans-serif;
color: #ccc;
}
.logo {
position: absolute;
top: 50%;
left: 50%;
width: 150px;
height: 80px;
margin-left: -75px;
margin-top: -40px;
}
...
CSS