You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-302Lines changed: 2 additions & 302 deletions
Original file line number
Diff line number
Diff line change
@@ -14,265 +14,16 @@ Options for adding Less.js to your project:
14
14
*[Download the latest release][download]
15
15
* Clone the repo: `git clone git://github.com/less/less.js.git`
16
16
17
-
18
-
19
-
## Feature Highlights
20
-
LESS extends CSS with dynamic features such as:
21
-
22
-
*[nesting](#nesting)
23
-
*[variables](#variables)
24
-
*[operations](#operations)
25
-
*[mixins](#mixins)
26
-
*[extend](#extend) (selector inheritance)
27
-
28
-
To learn about the many other features Less.js has to offer please visit [http://lesscss.org](http://lesscss.org) and [the Less.js wiki][wiki]
29
-
30
-
31
-
### Examples
32
-
#### nesting
33
-
Take advantage of nesting to make code more readable and maintainable. This:
34
-
35
-
```less
36
-
.nav>li>a {
37
-
border: 1pxsolid#f5f5f5;
38
-
&:hover {
39
-
border-color: #ddd;
40
-
}
41
-
}
42
-
```
43
-
44
-
renders to:
45
-
46
-
```css
47
-
.nav>li>a {
48
-
border: 1pxsolid#f5f5f5;
49
-
}
50
-
.nav>li>a:hover {
51
-
border-color: #ddd;
52
-
}
53
-
```
54
-
55
-
56
-
#### variables
57
-
Updated commonly used values from a single location.
58
-
59
-
```less
60
-
// Variables ("inline" comments like this can be used)
61
-
@link-color: #428bca; // appears as "sea blue"
62
-
63
-
/* Or "block comments" that span
64
-
multiple lines, like this */
65
-
a {
66
-
color: @link-color; // use the variable in styles
67
-
}
68
-
```
69
-
70
-
Variables can also be used in `@import` statements, URLs, selector names, and more.
71
-
72
-
73
-
74
-
#### operations
75
-
Continuing with the same example above, we can use our variables even easier to maintain with _operations_, which enables the use of addition, subraction, multiplication and division in your styles:
76
-
77
-
```less
78
-
// Variables
79
-
@link-color: #428bca;
80
-
@link-color-hover: darken(@link-color, 10%);
81
-
82
-
// Styles
83
-
a {
84
-
color: @link-color;
85
-
}
86
-
a:hover {
87
-
color: @link-color-hover;
88
-
}
89
-
```
90
-
renders to:
91
-
92
-
```css
93
-
a {
94
-
color: #428bca;
95
-
}
96
-
a:hover {
97
-
color: #3071a9;
98
-
}
99
-
```
100
-
101
-
#### mixins
102
-
##### "implicit" mixins
103
-
Mixins enable you to apply the styles of one selector inside another selector like this:
104
-
105
-
```less
106
-
// Variables
107
-
@link-color: #428bca;
108
-
109
-
// Any "regular" class...
110
-
.link {
111
-
color: @link-color;
112
-
}
113
-
a {
114
-
font-weight: bold;
115
-
.link; // ...can be used as an "implicit" mixin
116
-
}
117
-
```
118
-
119
-
renders to:
120
-
121
-
```css
122
-
.link {
123
-
color: #428bca;
124
-
}
125
-
a {
126
-
font-weight: bold;
127
-
color: #428bca;
128
-
}
129
-
```
130
-
131
-
So any selector can be an "implicit mixin". We'll show you a DRYer way to do this below.
132
-
133
-
134
-
135
-
##### parametric mixins
136
-
Mixins can also accept parameters:
137
-
138
-
```less
139
-
// Transition mixin
140
-
.transition(@transition) {
141
-
-webkit-transition: @transition;
142
-
-moz-transition: @transition;
143
-
-o-transition: @transition;
144
-
transition: @transition;
145
-
}
146
-
```
147
-
148
-
used like this:
149
-
150
-
```less
151
-
// Variables
152
-
@link-color: #428bca;
153
-
@link-color-hover: darken(@link-color, 10%);
154
-
155
-
//Transition mixin would be anywhere here
156
-
157
-
a {
158
-
font-weight: bold;
159
-
color: @link-color;
160
-
.transition(color.2sease-in-out);
161
-
// Hover state
162
-
&:hover {
163
-
color: @link-color-hover;
164
-
}
165
-
}
166
-
```
167
-
168
-
renders to:
169
-
170
-
```css
171
-
a {
172
-
font-weight: bold;
173
-
color: #428bca;
174
-
-webkit-transition: color0.2sease-in-out;
175
-
-moz-transition: color0.2sease-in-out;
176
-
-o-transition: color0.2sease-in-out;
177
-
transition: color0.2sease-in-out;
178
-
}
179
-
a:hover {
180
-
color: #3071a9;
181
-
}
182
-
```
183
-
184
-
185
-
#### extend
186
-
The `extend` feature can be thought of as the _inverse_ of mixins. It accomplishes the goal of "borrowing styles", but rather than copying all the rules of _Selector A_ over to _Selector B_, `extend` copies the name of the _inheriting selector_ (_Selector B_) over to the _extending selector_ (_Selector A_). So continuing with the example used for [mixins](#mixins) above, extend works like this:
For general information on the language, configuration options or usage visit [lesscss.org](http://lesscss.org) or [the less wiki][wiki].
19
+
For general information on the language, configuration options or usage visit [lesscss.org](http://lesscss.org).
266
20
267
21
Here are other resources for using Less.js:
268
22
269
23
*[stackoverflow.com][so] is a great place to get answers about Less.
270
-
*[node.js tools](https://github.com/less/less.js/wiki/Converting-LESS-to-CSS) for converting Less to CSS
271
-
*[GUI compilers for Less](https://github.com/less/less.js/wiki/GUI-compilers-that-use-LESS.js)
272
24
*[Less.js Issues][issues] for reporting bugs
273
25
274
26
275
-
276
27
## Contributing
277
28
Please read [CONTRIBUTING.md](./CONTRIBUTING.md). Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
To install all the dependencies for less development, run:
300
-
301
-
```shell
302
-
npm install
303
-
```
304
-
305
-
If you haven't run grunt before, install grunt-cli globally so you can just run `grunt`
306
-
307
-
```shell
308
-
npm install grunt-cli -g
309
-
```
310
-
311
-
You should now be able to build Less.js, run tests, benchmarking, and other tasks listed in the Gruntfile.
312
-
313
-
## Using Less.js Grunt
314
-
315
-
Tests, benchmarking and building is done using Grunt `~0.4.1`. If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to install and use Grunt plugins, which are necessary for development with Less.js.
316
-
317
-
The Less.js [Gruntfile](Gruntfile.js) is configured with the following "convenience tasks" :
318
-
319
-
#### test - `grunt`
320
-
Runs jshint, nodeunit and headless jasmine tests using [phantomjs](http://code.google.com/p/phantomjs/). You must have phantomjs installed for the jasmine tests to run.
321
-
322
-
#### test - `grunt benchmark`
323
-
Runs the benchmark suite.
324
-
325
-
#### build for testing browser - 'grunt browser'
326
-
This builds less.js and puts it in 'test/browser/less.js'
Builds Less.js from from the `/lib/less` source files. This is done by the developer releasing a new release, do not do this if you are creating a pull request.
330
-
331
-
#### readme - `grunt readme`
332
-
Build the README file from [a template](build/README.md) to ensure that metadata is up-to-date and (more likely to be) correct.
333
-
334
-
Please review the [Gruntfile](Gruntfile.js) to become acquainted with the other available tasks.
335
-
336
-
**Please note** that if you have any issues installing dependencies or running any of the Gruntfile commands, please make sure to uninstall any previous versions, both in the local node_modules directory, and clear your global npm cache, and then try running `npm install` again. After that if you still have issues, please let us know about it so we can help.
0 commit comments