123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662 |
- @nice-blue: #5B83AD;
- @light-blue: @nice-blue + #111;
- #header {
- color: @light-blue;
- }
- #header {
- color: #6c94be;
- }
- .bordered {
- border-top: dotted 1px black;
- border-bottom: solid 2px black;
- }
- #menu a {
- color: #111;
- .bordered;
- }
- .post a {
- color: red;
- .bordered;
- }
- #header {
- color: black;
- }
- #header .navigation {
- font-size: 12px;
- }
- #header .logo {
- width: 300px;
- }
- #header {
- color: black;
- .navigation {
- font-size: 12px;
- }
- .logo {
- width: 300px;
- }
- }
- .clearfix {
- display: block;
- zoom: 1;
- &:after {
- content: " ";
- display: block;
- font-size: 0;
- height: 0;
- clear: both;
- visibility: hidden;
- }
- }
- .screen-color {
- @media screen {
- color: green;
- @media (min-width: 768px) {
- color: red;
- }
- }
- @media tv {
- color: black;
- }
- }
- @media screen {
- .screen-color {
- color: green;
- }
- }
- @media screen and (min-width: 768px) {
- .screen-color {
- color: red;
- }
- }
- @media tv {
- .screen-color {
- color: black;
- }
- }
- #a {
- color: blue;
- @font-face {
- src: made-up-url;
- }
- padding: 2 2 2 2;
- }
- #a {
- color: blue;
- }
- @font-face {
- src: made-up-url;
- }
- #a {
- padding: 2 2 2 2;
- }
- // numbers are converted into the same units
- @conversion-1: 5cm + 10mm; // result is 6cm
- @conversion-2: 2 - 3cm - 5mm; // result is -1.5cm
- // conversion is impossible
- @incompatible-units: 2 + 5px - 3cm; // result is 4px
- // example with variables
- @base: 5%;
- @filler: @base * 2; // result is 10%
- @other: @base + @filler; // result is 15%
- @base: 2cm * 3mm; // result is 6cm
- @color: #224488 / 2; //results in #112244
- background-color: #112244 + #111; // result is #223355
- .weird-element {
- content: ~"^//* some horrible but needed css hack";
- }
- @base: #f04615;
- @width: 0.5;
- .class {
- width: percentage(@width); // returns `50%`
- color: saturate(@base, 5%);
- background-color: spin(lighten(@base, 25%), 8);
- }
- #bundle {
- .button {
- display: block;
- border: 1px solid black;
- background-color: grey;
- &:hover {
- background-color: white
- }
- }
- .tab { /* ... */ }
- .citation { /* ... */ }
- }
- #header a {
- color: orange;
- #bundle > .button;
- }
- @var: red;
- #page {
- @var: white;
- #header {
- color: @var; // white
- }
- }
- @var: red;
- #page {
- #header {
- color: @var; // white
- }
- @var: white;
- }
- /* One hell of a block
- style comment! */
- @var: red;
- // Get in line!
- @var: white;
- @import "library"; // library.less
- @import "typo.css";
- a,
- .link {
- color: #428bca;
- }
- .widget {
- color: #fff;
- background: #428bca;
- }
- // Variables
- @link-color: #428bca; // sea blue
- @link-color-hover: darken(@link-color, 10%);
- // Usage
- a,
- .link {
- color: @link-color;
- }
- a:hover {
- color: @link-color-hover;
- }
- .widget {
- color: #fff;
- background: @link-color;
- }
- // Variables
- @my-selector: banner;
- // Usage
- .@{my-selector} {
- font-weight: bold;
- line-height: 40px;
- margin: 0 auto;
- }
- .banner {
- font-weight: bold;
- line-height: 40px;
- margin: 0 auto;
- }
- // Variables
- @images: "../img";
- // Usage
- body {
- color: #444;
- background: url("@{images}/white-sand.png");
- }
- // Variables
- @themes: "../../src/themes";
- // Usage
- @import "@{themes}/tidal-wave.less";
- @property: color;
- .widget {
- @{property}: #0ee;
- background-@{property}: #999;
- }
- .widget {
- color: #0ee;
- background-color: #999;
- }
- @fnord: "I am fnord.";
- @var: "fnord";
- content: @@var;
- content: "I am fnord.";
- .lazy-eval {
- width: @var;
- }
- @var: @a;
- @a: 9%;
- .lazy-eval-scope {
- width: @var;
- @a: 9%;
- }
- @var: @a;
- @a: 100%;
- .lazy-eval-scope {
- width: 9%;
- }
- @var: 0;
- .class {
- @var: 1;
- .brass {
- @var: 2;
- three: @var;
- @var: 3;
- }
- one: @var;
- }
- .class {
- one: 1;
- }
- .class .brass {
- three: 3;
- }
- // library
- @base-color: green;
- @dark-color: darken(@base-color, 10%);
- // use of library
- @import "library.less";
- @base-color: red;
- nav ul {
- &:extend(.inline);
- background: blue;
- }
- nav ul {
- &:extend(.inline);
- background: blue;
- }
- .inline {
- color: red;
- }
- nav ul {
- background: blue;
- }
- .inline,
- nav ul {
- color: red;
- }
- .a:extend(.b) {}
- // the above block does the same thing as the below block
- .a {
- &:extend(.b);
- }
- .c:extend(.d all) {
- // extends all instances of ".d" e.g. ".x.d" or ".d.x"
- }
- .c:extend(.d) {
- // extends only instances where the selector will be output as just ".d"
- }
- .e:extend(.f) {}
- .e:extend(.g) {}
- // the above an the below do the same thing
- .e:extend(.f, .g) {}
- .big-division,
- .big-bag:extend(.bag),
- .big-bucket:extend(.bucket) {
- // body
- }
- pre:hover,
- .some-class {
- &:extend(div pre);
- }
- pre:hover:extend(div pre),
- .some-class:extend(div pre) {}
- .bucket {
- tr { // nested ruleset with target selector
- color: blue;
- }
- }
- .some-class:extend(.bucket tr) {} // nested ruleset is recognized
- .bucket tr,
- .some-class {
- color: blue;
- }
- .bucket {
- tr & { // nested ruleset with target selector
- color: blue;
- }
- }
- .some-class:extend(tr .bucket) {} // nested ruleset is recognized
- tr .bucket,
- .some-class {
- color: blue;
- }
- .a.class,
- .class.a,
- .class > .a {
- color: blue;
- }
- .test:extend(.class) {} // this will NOT match the any selectors above
- *.class {
- color: blue;
- }
- .noStar:extend(.class) {} // this will NOT match the *.class selector
- *.class {
- color: blue;
- }
- link:hover:visited {
- color: blue;
- }
- .selector:extend(link:visited:hover) {}
- link:hover:visited {
- color: blue;
- }
- :nth-child(1n+3) {
- color: blue;
- }
- .child:extend(:nth-child(n+3)) {}
- :nth-child(1n+3) {
- color: blue;
- }
- [title=identifier] {
- color: blue;
- }
- [title='identifier'] {
- color: blue;
- }
- [title="identifier"] {
- color: blue;
- }
- .noQuote:extend([title=identifier]) {}
- .singleQuote:extend([title='identifier']) {}
- .doubleQuote:extend([title="identifier"]) {}
- [title=identifier],
- .noQuote,
- .singleQuote,
- .doubleQuote {
- color: blue;
- }
- [title='identifier'],
- .noQuote,
- .singleQuote,
- .doubleQuote {
- color: blue;
- }
- [title="identifier"],
- .noQuote,
- .singleQuote,
- .doubleQuote {
- color: blue;
- }
- .a.b.test,
- .test.c {
- color: orange;
- }
- .test {
- &:hover {
- color: green;
- }
- }
- .replacement:extend(.test all) {}
- .a.b.test,
- .test.c,
- .a.b.replacement,
- .replacement.c {
- color: orange;
- }
- .test:hover,
- .replacement:hover {
- color: green;
- }
- @variable: .bucket;
- @{variable} { // interpolated selector
- color: blue;
- }
- .some-class:extend(.bucket) {} // does nothing, no match is found
- .bucket {
- color: blue;
- }
- .some-class:extend(@{variable}) {} // interpolated selector matches nothing
- @variable: .bucket;
- .bucket {
- color: blue;
- }
- .bucket {
- color: blue;
- }
- @{variable}:extend(.bucket) {}
- @variable: .selector;
- .bucket, .selector {
- color: blue;
- }
- @media print {
- .screenClass:extend(.selector) {} // extend inside media
- .selector { // this will be matched - it is in the same media
- color: black;
- }
- }
- .selector { // ruleset on top of style sheet - extend ignores it
- color: red;
- }
- @media screen {
- .selector { // ruleset inside another media - extend ignores it
- color: blue;
- }
- }
- @media print {
- .selector,
- .screenClass { /* ruleset inside the same media was extended */
- color: black;
- }
- }
- .selector { /* ruleset on top of style sheet was ignored */
- color: red;
- }
- @media screen {
- .selector { /* ruleset inside another media was ignored */
- color: blue;
- }
- }
- @media screen {
- .screenClass:extend(.selector) {} // extend inside media
- @media (min-width: 1023px) {
- .selector { // ruleset inside nested media - extend ignores it
- color: blue;
- }
- }
- }
- @media screen and (min-width: 1023px) {
- .selector { /* ruleset inside another nested media was ignored */
- color: blue;
- }
- }
- @media screen {
- .selector { /* ruleset inside nested media - top level extend works */
- color: blue;
- }
- @media (min-width: 1023px) {
- .selector { /* ruleset inside nested media - top level extend works */
- color: blue;
- }
- }
- }
- .topLevel:extend(.selector) {} /* top level extend matches everything */
- @media screen {
- .selector,
- .topLevel { /* ruleset inside media was extended */
- color: blue;
- }
- }
- @media screen and (min-width: 1023px) {
- .selector,
- .topLevel { /* ruleset inside nested media was extended */
- color: blue;
- }
- }
- .alert-info,
- .widget {
- /* declarations */
- }
- .alert:extend(.alert-info, .widget) {}
- .alert-info,
- .widget,
- .alert,
- .alert {
- /* declarations */
- }
- .animal {
- background-color: black;
- color: white;
- }
- .animal {
- background-color: black;
- color: white;
- }
- .bear {
- background-color: brown;
- }
- .animal {
- background-color: black;
- color: white;
- }
- .bear {
- &:extend(.animal);
- background-color: brown;
- }
- .my-inline-block() {
- display: inline-block;
- font-size: 0;
- }
- .thing1 {
- .my-inline-block;
- }
- .thing2 {
- .my-inline-block;
- }
- .thing1 {
- display: inline-block;
- font-size: 0;
- }
- .thing2 {
- display: inline-block;
- font-size: 0;
- }
- .my-inline-block {
- display: inline-block;
- font-size: 0;
- }
- .thing1 {
- &:extend(.my-inline-block);
- }
- .thing2 {
- &:extend(.my-inline-block);
- }
- .my-inline-block,
- .thing1,
- .thing2 {
- display: inline-block;
- font-size: 0;
- }
- li.list > a {
- // list styles
- }
- button.list-style {
- &:extend(li.list > a); // use the same list styles
- }
- .a, #b {
- color: red;
- }
- .mixin-class {
- .a();
- }
- .mixin-id {
- #b();
- }
- .a, #b {
- color: red;
- }
- .mixin-class {
- color: red;
- }
- .mixin-id {
- color: red;
- }
- // these two statements do the same thing:
- .a();
- .a;
- .my-mixin {
- color: black;
- }
- .my-other-mixin() {
- background: white;
- }
- .class {
- .my-mixin;
- .my-other-mixin;
- }
- .my-mixin {
- color: black;
- }
- .class {
- color: black;
- background: white;
- }
- .my-hover-mixin() {
- &:hover {
- border: 1px solid red;
- }
- }
- button {
- .my-hover-mixin();
- }
- button:hover {
- border: 1px solid red;
- }
- #outer {
- .inner {
- color: red;
- }
- }
- .c {
- #outer > .inner;
- }
- // all do the same thing
- #outer > .inner;
- #outer > .inner();
- #outer .inner;
- #outer .inner();
- #outer.inner;
- #outer.inner();
- #my-library {
- .my-mixin() {
- color: black;
- }
- }
- // which can be used like this
- .class {
- #my-library > .my-mixin();
- }
- #namespace when (@mode=huge) {
- .mixin() { /* */ }
- }
- #namespace {
- .mixin() when (@mode=huge) { /* */ }
- }
- #sp_1 when (default()) {
- #sp_2 when (default()) {
- .mixin() when not(default()) { /* */ }
- }
- }
- .foo (@bg: #f5f5f5, @color: #900) {
- background: @bg;
- color: @color;
- }
- .unimportant {
- .foo();
- }
- .important {
- .foo() !important;
- }
- .unimportant {
- background: #f5f5f5;
- color: #900;
- }
- .important {
- background: #f5f5f5 !important;
- color: #900 !important;
- }
- .border-radius(@radius) {
- -webkit-border-radius: @radius;
- -moz-border-radius: @radius;
- border-radius: @radius;
- }
- #header {
- .border-radius(4px);
- }
- .button {
- .border-radius(6px);
- }
- .border-radius(@radius: 5px) {
- -webkit-border-radius: @radius;
- -moz-border-radius: @radius;
- border-radius: @radius;
- }
- #header {
- .border-radius;
- }
- .wrap() {
- text-wrap: wrap;
- white-space: -moz-pre-wrap;
- white-space: pre-wrap;
- word-wrap: break-word;
- }
- pre { .wrap }
- pre {
- text-wrap: wrap;
- white-space: -moz-pre-wrap;
- white-space: pre-wrap;
- word-wrap: break-word;
- }
- .mixin(@color) {
- color-1: @color;
- }
- .mixin(@color; @padding: 2) {
- color-2: @color;
- padding-2: @padding;
- }
- .mixin(@color; @padding; @margin: 2) {
- color-3: @color;
- padding-3: @padding;
- margin: @margin @margin @margin @margin;
- }
- .some .selector div {
- .mixin(#008000);
- }
- .some .selector div {
- color-1: #008000;
- color-2: #008000;
- padding-2: 2;
- }
- .mixin(@color: black; @margin: 10px; @padding: 20px) {
- color: @color;
- margin: @margin;
- padding: @padding;
- }
- .class1 {
- .mixin(@margin: 20px; @color: #33acfe);
- }
- .class2 {
- .mixin(#efca44; @padding: 40px);
- }
- .class1 {
- color: #33acfe;
- margin: 20px;
- padding: 20px;
- }
- .class2 {
- color: #efca44;
- margin: 10px;
- padding: 40px;
- }
- .box-shadow(@x: 0; @y: 0; @blur: 1px; @color: #000) {
- -webkit-box-shadow: @arguments;
- -moz-box-shadow: @arguments;
- box-shadow: @arguments;
- }
- .big-block {
- .box-shadow(2px; 5px);
- }
- .big-block {
- -webkit-box-shadow: 2px 5px 1px #000;
- -moz-box-shadow: 2px 5px 1px #000;
- box-shadow: 2px 5px 1px #000;
- }
- .mixin(/* ... */) {} // matches 0-N arguments
- .mixin() {} // matches exactly 0 arguments
- .mixin(@a: 1) {} // matches 0-1 arguments
- .mixin(@a: 1; /* ... */) {} // matches 0-N arguments
- .mixin(@a; /* ... */) {} // matches 1-N arguments
- .mixin(@a; @rest...) {
- // @rest is bound to arguments after @a
- // @arguments is bound to all arguments
- }
- .mixin(@s; @color) { /* ... */ }
- .class {
- .mixin(@switch; #888);
- }
- .mixin(dark; @color) {
- color: darken(@color, 10%);
- }
- .mixin(light; @color) {
- color: lighten(@color, 10%);
- }
- .mixin(@_; @color) {
- display: block;
- }
- @switch: light;
- .class {
- .mixin(@switch; #888);
- }
- .class {
- color: #a2a2a2;
- display: block;
- }
- .mixin(@a) {
- color: @a;
- }
- .mixin(@a; @b) {
- color: fade(@a; @b);
- }
- .mixin() {
- @width: 100%;
- @height: 200px;
- }
- .caller {
- .mixin();
- width: @width;
- height: @height;
- }
- .caller {
- width: 100%;
- height: 200px;
- }
- .average(@x, @y) {
- @average: ((@x + @y) / 2);
- }
- div {
- .average(16px, 50px); // "call" the mixin
- padding: @average; // use its "return" value
- }
- div {
- padding: 33px;
- }
- .mixin() {
- @size: in-mixin;
- @definedOnlyInMixin: in-mixin;
- }
- .class {
- margin: @size @definedOnlyInMixin;
- .mixin();
- }
- @size: globally-defined-value; // callers parent scope - no protection
- .class {
- margin: in-mixin in-mixin;
- }
- .unlock(@value) { // outer mixin
- .doSomething() { // nested mixin
- declaration: @value;
- }
- }
- #namespace {
- .unlock(5); // unlock doSomething mixin
- .doSomething(); //nested mixin was copied here and is usable
- }
- #namespace {
- declaration: 5;
- }
- // declare detached ruleset
- @detached-ruleset: { background: red; };
- // use detached ruleset
- .top {
- @detached-ruleset();
- }
- .top {
- background: red;
- }
- .desktop-and-old-ie(@rules) {
- @media screen and (min-width: 1200px) { @rules(); }
- html.lt-ie9 & { @rules(); }
- }
- header {
- background-color: blue;
- .desktop-and-old-ie({
- background-color: red;
- });
- }
- header {
- background-color: blue;
- }
- @media screen and (min-width: 1200px) {
- header {
- background-color: red;
- }
- }
- html.lt-ie9 header {
- background-color: red;
- }
- @my-ruleset: {
- .my-selector {
- background-color: black;
- }
- };
- @my-ruleset: {
- .my-selector {
- @media tv {
- background-color: black;
- }
- }
- };
- @media (orientation:portrait) {
- @my-ruleset();
- }
- @media (orientation: portrait) and tv {
- .my-selector {
- background-color: black;
- }
- }
- // detached ruleset with a mixin
- @detached-ruleset: {
- .mixin() {
- color:blue;
- }
- };
- // call detached ruleset
- .caller {
- @detached-ruleset();
- .mixin();
- }
- .caller {
- color: blue;
- }
- @detached-ruleset: {
- @color:blue; // this variable is private
- };
- .caller {
- color: @color; // syntax error
- }
- @detached-ruleset: {
- caller-variable: @caller-variable; // variable is undefined here
- .caller-mixin(); // mixin is undefined here
- };
- selector {
- // use detached ruleset
- @detached-ruleset();
- // define variable and mixin needed inside the detached ruleset
- @caller-variable: value;
- .caller-mixin() {
- variable: declaration;
- }
- }
- selector {
- caller-variable: value;
- variable: declaration;
- }
- @variable: global;
- @detached-ruleset: {
- // will use global variable, because it is accessible
- // from detached-ruleset definition
- variable: @variable;
- };
- selector {
- @detached-ruleset();
- @variable: value; // variable defined in caller - will be ignored
- }
- selector {
- variable: global;
- }
- @detached-1: { scope-detached: @one @two; };
- .one {
- @one: visible;
- .two {
- @detached-2: @detached-1; // copying/renaming ruleset
- @two: visible; // ruleset can not see this variable
- }
- }
- .use-place {
- .one > .two();
- @detached-2();
- }
- #space {
- .importer-1() {
- @detached: { scope-detached: @variable; }; // define detached ruleset
- }
- }
- .importer-2() {
- @variable: value; // unlocked detached ruleset CAN see this variable
- #space > .importer-1(); // unlock/import detached ruleset
- }
- .use-place {
- .importer-2(); // unlock/import detached ruleset second time
- @detached();
- }
- .use-place {
- scope-detached: value;
- }
- @my-ruleset:{.my-selector{@media tv{background-color:black;}}};
- .foo {
- background: #900;
- }
- @import "this-is-valid.less";
- @import "foo"; // foo.less is imported
- @import "foo.less"; // foo.less is imported
- @import "foo.php"; // foo.php imported as a less file
- @import "foo.css"; // statement left in place, as-is
- .navbar:extend(.navbar all) {}
- @import (less) "foo.css";
- @import (css) "foo.less";
- @import "foo.less";
- @import (once) "foo.less";
- @import (once) "foo.less"; // this statement will be ignored
- // file: foo.less
- .a {
- color: green;
- }
- // file: main.less
- @import (multiple) "foo.less";
- @import (multiple) "foo.less";
- .a {
- color: green;
- }
- .a {
- color: green;
- }
- .mixin (@a) when (lightness(@a) >= 50%) {
- background-color: black;
- }
- .mixin (@a) when (lightness(@a) < 50%) {
- background-color: white;
- }
- .mixin (@a) {
- color: @a;
- }
- .class1 { .mixin(#ddd) }
- .class2 { .mixin(#555) }
- .class1 {
- background-color: black;
- color: #ddd;
- }
- .class2 {
- background-color: white;
- color: #555;
- }
- .truth (@a) when (@a) { /* ... */ }
- .truth (@a) when (@a = true) { /* ... */ }
- .class {
- .truth(40); // Will not match any of the above definitions.
- }
- @media: mobile;
- .mixin (@a) when (@media = mobile) { /* ... */ }
- .mixin (@a) when (@media = desktop) { /* ... */ }
- .max (@a; @b) when (@a > @b) { width: @a }
- .max (@a; @b) when (@a < @b) { width: @b }
- .mixin (@a) when (isnumber(@a)) and (@a > 0) { /* ... */ }
- .mixin (@a) when (@a > 10), (@a < -10) { /* ... */ }
- .mixin (@b) when not (@b > 0) { /* ... */ }
- .mixin (@a; @b: 0) when (isnumber(@b)) { /* ... */ }
- .mixin (@a; @b: black) when (iscolor(@b)) { /* ... */ }
- .mixin (@a) when (@a > 0) { /* ... */ }
- .mixin (@a) when (default()) { /* ... */ } // matches only if first mixin does not, i.e. when @a <= 0
- .my-optional-style() when (@my-option = true) {
- button {
- color: white;
- }
- }
- .my-optional-style();
- button when (@my-option = true) {
- color: white;
- }
- & when (@my-option = true) {
- button {
- color: white;
- }
- a {
- color: blue;
- }
- }
- .loop(@counter) when (@counter > 0) {
- .loop((@counter - 1)); // next iteration
- width: (10px * @counter); // code for each iteration
- }
- div {
- .loop(5); // launch the loop
- }
- div {
- width: 10px;
- width: 20px;
- width: 30px;
- width: 40px;
- width: 50px;
- }
- .generate-columns(4);
- .generate-columns(@n, @i: 1) when (@i =< @n) {
- .column-@{i} {
- width: (@i * 100% / @n);
- }
- .generate-columns(@n, (@i + 1));
- }
- .column-1 {
- width: 25%;
- }
- .column-2 {
- width: 50%;
- }
- .column-3 {
- width: 75%;
- }
- .column-4 {
- width: 100%;
- }
- .mixin() {
- box-shadow+: inset 0 0 10px #555;
- }
- .myclass {
- .mixin();
- box-shadow+: 0 0 20px black;
- }
- .myclass {
- box-shadow: inset 0 0 10px #555, 0 0 20px black;
- }
- .mixin() {
- transform+_: scale(2);
- }
- .myclass {
- .mixin();
- transform+_: rotate(15deg);
- }
- .myclass {
- transform: scale(2) rotate(15deg);
- }
- a {
- color: blue;
- &:hover {
- color: green;
- }
- }
- a {
- color: blue;
- }
- a:hover {
- color: green;
- }
- .button {
- &-ok {
- background-image: url("ok.png");
- }
- &-cancel {
- background-image: url("cancel.png");
- }
- &-custom {
- background-image: url("custom.png");
- }
- }
- .button-ok {
- background-image: url("ok.png");
- }
- .button-cancel {
- background-image: url("cancel.png");
- }
- .button-custom {
- background-image: url("custom.png");
- }
- .link {
- & + & {
- color: red;
- }
- & & {
- color: green;
- }
- && {
- color: blue;
- }
- &, &ish {
- color: cyan;
- }
- }
- .link + .link {
- color: red;
- }
- .link .link {
- color: green;
- }
- .link.link {
- color: blue;
- }
- .link, .linkish {
- color: cyan;
- }
- .grand {
- .parent {
- & > & {
- color: red;
- }
- & & {
- color: green;
- }
- && {
- color: blue;
- }
- &, &ish {
- color: cyan;
- }
- }
- }
- .grand .parent > .grand .parent {
- color: red;
- }
- .grand .parent .grand .parent {
- color: green;
- }
- .grand .parent.grand .parent {
- color: blue;
- }
- .grand .parent,
- .grand .parentish {
- color: cyan;
- }
- .header {
- .menu {
- border-radius: 5px;
- .no-borderradius & {
- background-image: url('images/button-background.png');
- }
- }
- }
- .header .menu {
- border-radius: 5px;
- }
- .no-borderradius .header .menu {
- background-image: url('images/button-background.png');
- }
- p, a, ul, li {
- border-top: 2px dotted #366;
- & + & {
- border-top: 0;
- }
- }
- p,
- a,
- ul,
- li {
- border-top: 2px dotted #366;
- }
- p + p,
- p + a,
- p + ul,
- p + li,
- a + p,
- a + a,
- a + ul,
- a + li,
- ul + p,
- ul + a,
- ul + ul,
- ul + li,
- li + p,
- li + a,
- li + ul,
- li + li {
- border-top: 0;
- }
- .foobar {
- &:extend(.foo);
- }
- .thing {
- &:hover {
- background-color: blue;
- .thing-child {}
- }
- }
- .foo,
- // Comment
- .bar {
- // Comment
- color: red; // Comment
- }
- // Variables
- @link-color: #428bca; // Comment
- [href]:hover &, // Comment
- [href]:focus &, // Comment
- [href]:active & {
- .tooltip {
- opacity: 1;
- }
- }
- // Usage
- @import // Comment
- "@{themes}/tidal-wave.less";
|