mirror of
https://github.com/less/less.js.git
synced 2026-01-23 06:07:56 -05:00
Add Sass like extend
This commit is contained in:
15
test/css/extend-clearfix.css
Normal file
15
test/css/extend-clearfix.css
Normal file
@@ -0,0 +1,15 @@
|
||||
.clearfix, .foo, .bar {
|
||||
*zoom: 1;
|
||||
}
|
||||
.clearfix:after, .foo:after, .bar:after {
|
||||
content: '';
|
||||
display: block;
|
||||
clear: both;
|
||||
height: 0;
|
||||
}
|
||||
.foo {
|
||||
color: red;
|
||||
}
|
||||
.bar {
|
||||
color: blue;
|
||||
}
|
||||
15
test/css/extend-nest.css
Normal file
15
test/css/extend-nest.css
Normal file
@@ -0,0 +1,15 @@
|
||||
.sidebar, .sidebar2, .type1 .sidebar3 {
|
||||
width: 300px;
|
||||
background: red;
|
||||
}
|
||||
.sidebar .box, .sidebar2 .box, .type1 .sidebar3 .box {
|
||||
background: #FFF;
|
||||
border: 1px solid #000;
|
||||
margin: 10px 0;
|
||||
}
|
||||
.sidebar2 {
|
||||
background: blue;
|
||||
}
|
||||
.type1 .sidebar3 {
|
||||
background: green;
|
||||
}
|
||||
24
test/css/extend.css
Normal file
24
test/css/extend.css
Normal file
@@ -0,0 +1,24 @@
|
||||
.error, .badError {
|
||||
border: 1px #f00;
|
||||
background: #fdd;
|
||||
}
|
||||
.error.intrusion, .badError.intrusion {
|
||||
font-size: 1.3em;
|
||||
font-weight: bold;
|
||||
}
|
||||
.intrusion .error, .intrusion .badError {
|
||||
display: none;
|
||||
}
|
||||
.badError {
|
||||
border-width: 3px;
|
||||
}
|
||||
.foo .bar,
|
||||
.foo .baz,
|
||||
.ext1 .ext2 .bar,
|
||||
.ext1 .ext2 .baz,
|
||||
.ext3 .bar,
|
||||
.ext4 .bar,
|
||||
.ext3 .baz,
|
||||
.ext4 .baz {
|
||||
display: none;
|
||||
}
|
||||
19
test/less/extend-clearfix.less
Normal file
19
test/less/extend-clearfix.less
Normal file
@@ -0,0 +1,19 @@
|
||||
.clearfix {
|
||||
*zoom: 1;
|
||||
&:after {
|
||||
content: '';
|
||||
display: block;
|
||||
clear: both;
|
||||
height: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.foo {
|
||||
+.clearfix;
|
||||
color: red;
|
||||
}
|
||||
|
||||
.bar {
|
||||
+.clearfix;
|
||||
color: blue;
|
||||
}
|
||||
22
test/less/extend-nest.less
Normal file
22
test/less/extend-nest.less
Normal file
@@ -0,0 +1,22 @@
|
||||
.sidebar {
|
||||
width: 300px;
|
||||
background: red;
|
||||
|
||||
.box {
|
||||
background: #FFF;
|
||||
border: 1px solid #000;
|
||||
margin: 10px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar2 {
|
||||
+.sidebar;
|
||||
background: blue;
|
||||
}
|
||||
|
||||
.type1 {
|
||||
.sidebar3 {
|
||||
+.sidebar;
|
||||
background: green;
|
||||
}
|
||||
}
|
||||
27
test/less/extend.less
Normal file
27
test/less/extend.less
Normal file
@@ -0,0 +1,27 @@
|
||||
.error {
|
||||
border: 1px #f00;
|
||||
background: #fdd;
|
||||
}
|
||||
.error.intrusion {
|
||||
font-size: 1.3em;
|
||||
font-weight: bold;
|
||||
}
|
||||
.intrusion .error {
|
||||
display: none;
|
||||
}
|
||||
.badError {
|
||||
+.error;
|
||||
border-width: 3px;
|
||||
}
|
||||
|
||||
.foo .bar, .foo .baz {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ext1 .ext2 {
|
||||
+.foo;
|
||||
}
|
||||
|
||||
.ext3, .ext4 {
|
||||
+.foo;
|
||||
}
|
||||
Reference in New Issue
Block a user