| 1 |
|
| 2 |
@mixin something { |
| 3 |
color: red; |
| 4 |
pre { |
| 5 |
height: 200px; |
| 6 |
} |
| 7 |
} |
| 8 |
|
| 9 |
div { |
| 10 |
color: blue; |
| 11 |
@include something; |
| 12 |
} |
| 13 |
|
| 14 |
@mixin something($color) { |
| 15 |
color: $color; |
| 16 |
|
| 17 |
div { |
| 18 |
height: 20px; |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
@mixin cool($a, $b, $c) { |
| 23 |
height: $a + $b + $c; |
| 24 |
} |
| 25 |
|
| 26 |
span { |
| 27 |
@include something(blue); |
| 28 |
} |
| 29 |
|
| 30 |
html { |
| 31 |
@include cool(10px, 12px, 21px); |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
@mixin hello_world { |
| 36 |
height: 20px; |
| 37 |
} |
| 38 |
|
| 39 |
del { |
| 40 |
@include hello-world; |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
// variable shadowing |
| 45 |
|
| 46 |
|
| 47 |
$color: white; |
| 48 |
@mixin colors($color: blue) { |
| 49 |
color: $color; |
| 50 |
} |
| 51 |
|
| 52 |
div { |
| 53 |
color: $color; |
| 54 |
@include colors(); |
| 55 |
color: $color; |
| 56 |
} |
| 57 |
|
| 58 |
@mixin linear-gradient($from, $to, $pos: left top) { |
| 59 |
background-image: linear-gradient($pos, $from, $to); |
| 60 |
} |
| 61 |
|
| 62 |
div { |
| 63 |
@include linear-gradient(red, green); |
| 64 |
} |
| 65 |
|
| 66 |
@mixin box-shadow($shadows...) { |
| 67 |
-moz-box-shadow: $shadows; |
| 68 |
-webkit-box-shadow: $shadows; |
| 69 |
box-shadow: $shadows; |
| 70 |
} |
| 71 |
|
| 72 |
div { |
| 73 |
@include box-shadow(10px 10px 5px #888); |
| 74 |
@include box-shadow(inset 10px 10px #888, -10px -10px #f4f4f4); |
| 75 |
} |
| 76 |
|
| 77 |
@mixin nested { |
| 78 |
@include something(red); |
| 79 |
} |
| 80 |
|
| 81 |
div { |
| 82 |
p { |
| 83 |
.class { |
| 84 |
@include nested; |
| 85 |
} |
| 86 |
|
| 87 |
@include nested; |
| 88 |
|
| 89 |
.top { |
| 90 |
top: 0; |
| 91 |
|
| 92 |
div { |
| 93 |
color: red; |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
color: blue; |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
// mixin content (http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixin-content) |
| 102 |
@mixin content-simple { |
| 103 |
div.mixin-content-simple { |
| 104 |
@content; |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
@mixin content-with-arg ( $background ) { |
| 109 |
div.mixin-content-with-arg { |
| 110 |
background: $background; |
| 111 |
@content; |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
@include content-simple { |
| 116 |
color: red; |
| 117 |
} |
| 118 |
|
| 119 |
@include content-with-arg($background: blue) { |
| 120 |
color: red; |
| 121 |
} |
| 122 |
|
| 123 |
@include content-with-arg($background: purple) { |
| 124 |
@include hello_world; |
| 125 |
} |
| 126 |
|
| 127 |
@include content-simple { |
| 128 |
@include cool(10px, 12px, 21px); |
| 129 |
} |
| 130 |
|
| 131 |
@include content-simple { |
| 132 |
@include something(orange); |
| 133 |
} |
| 134 |
|
| 135 |
@include content-with-arg($background: purple) { |
| 136 |
@include cool(10px, 12px, 21px); |
| 137 |
} |
| 138 |
|
| 139 |
@include content-with-arg($background: purple) { |
| 140 |
@include something(orange); |
| 141 |
} |
| 142 |
|
| 143 |
@mixin wallpaper($image, $top: 0, $right: 0, $bottom: 0, $left: 0) { |
| 144 |
background: $image; |
| 145 |
position: absolute; |
| 146 |
top: $top; |
| 147 |
right: $right; |
| 148 |
bottom: $bottom; |
| 149 |
left: $left; |
| 150 |
} |
| 151 |
|
| 152 |
@mixin logo($offsets...) { |
| 153 |
@include wallpaper(url(/images/logo.png), $offsets...); |
| 154 |
} |
| 155 |
|
| 156 |
#please-wait { |
| 157 |
@include logo(1em, $left: 4em, $bottom: 3em); |
| 158 |
} |
| 159 |
|