/*LESS支持所有的CSS语法*/
* {
margin: 0;
padding: 0;
}
//less支持css所不支持的单行注释
//单行注释只会出现在less文件中
//less中声明变量
@jd-red: #e4e93c; //颜色变量
@half-opa: 0.5; //数值变量
@std-width: 4px; //尺寸变量
@base-font: 'SimHei'; //字符串变量
.box {
color: @jd-red;
opacity: @half-opa;
border: @std-width solid @jd-red;
}
@kongzi: '孔子曰:';
@mengzi: '孟子曰:';
@zhuangzi: '庄子曰:';
@author: 'zhuangzi';
.mingyan:before {
content: @@author;
}
.mingyan:after {
content: @@author;
}
//超级变量:混入/混合(mixin)
.bordered {
border-top: 10px solid #aaa;
border-right: 20px solid #aaa;
border-bottom: 30px solid #aaa;
border-left: 40px solid #aaa;
}
.h1 {
font-size: 36px;
.bordered;
}
.h2 {
font-size: 24px;
.bordered;
}
//带参混入
.box3(@w,@bc,@fc:#fff) {
border: @w solid @bc;
color: @fc;
}
.alert {
.box3(2px,#bbb, #ccc);
}
.carousel {
.box3(5px, #ddd);
}
//box5不会出现在css文件中
.box5() {
margin: 5px;
padding: 6px;
}
.well {
.box5;
}
.dropdown {
.box5;
}
//引导混入
.box6(@w) when(@w<10px){
border: @w solid #000;
}
.box6(@w) when(@w>=10px){
border: @w solid #aaa;
}
.h6 {
.box6(1px);
}
.h1 {
.box6(50px);
}
//样式的嵌套
/*#navigator {
background: #aaa;
}
#navigator .logo {
margin: 10px;
}
#navigator .logo a {
text-decoration: none;
}
#navigator .logo a:hover {
text-decoration: underline;
}*/
#nav {
background: #aaa;
.logo {
margin: 10px;
a {
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
}
ul{
list-style: none;
li {
padding:0;
a{
border: 1px solid #aaa;
}
&:hover {
color: #ccc;
}
}
}
}
//运算
body {
color: #abc+#234;
background: #431 - #333;
}
.box6 {
width: image-width('../img/logo.png');
}
//函数
@std-red: #e4393c;
@light-red: lighten(@std-red, 15%);
@lighter-red: lighten(@std-red, 30%);
@dark-red: darken(@std-red, 15%);
@darker-red: darken(@std-red, 30%);
.box9 {
background: @lighter-red;
border: 1px solid @std-red;
color: @darker-red;
}
* {
margin: 0;
padding: 0;
}
//less支持css所不支持的单行注释
//单行注释只会出现在less文件中
//less中声明变量
@jd-red: #e4e93c; //颜色变量
@half-opa: 0.5; //数值变量
@std-width: 4px; //尺寸变量
@base-font: 'SimHei'; //字符串变量
.box {
color: @jd-red;
opacity: @half-opa;
border: @std-width solid @jd-red;
}
@kongzi: '孔子曰:';
@mengzi: '孟子曰:';
@zhuangzi: '庄子曰:';
@author: 'zhuangzi';
.mingyan:before {
content: @@author;
}
.mingyan:after {
content: @@author;
}
//超级变量:混入/混合(mixin)
.bordered {
border-top: 10px solid #aaa;
border-right: 20px solid #aaa;
border-bottom: 30px solid #aaa;
border-left: 40px solid #aaa;
}
.h1 {
font-size: 36px;
.bordered;
}
.h2 {
font-size: 24px;
.bordered;
}
//带参混入
.box3(@w,@bc,@fc:#fff) {
border: @w solid @bc;
color: @fc;
}
.alert {
.box3(2px,#bbb, #ccc);
}
.carousel {
.box3(5px, #ddd);
}
//box5不会出现在css文件中
.box5() {
margin: 5px;
padding: 6px;
}
.well {
.box5;
}
.dropdown {
.box5;
}
//引导混入
.box6(@w) when(@w<10px){
border: @w solid #000;
}
.box6(@w) when(@w>=10px){
border: @w solid #aaa;
}
.h6 {
.box6(1px);
}
.h1 {
.box6(50px);
}
//样式的嵌套
/*#navigator {
background: #aaa;
}
#navigator .logo {
margin: 10px;
}
#navigator .logo a {
text-decoration: none;
}
#navigator .logo a:hover {
text-decoration: underline;
}*/
#nav {
background: #aaa;
.logo {
margin: 10px;
a {
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
}
ul{
list-style: none;
li {
padding:0;
a{
border: 1px solid #aaa;
}
&:hover {
color: #ccc;
}
}
}
}
//运算
body {
color: #abc+#234;
background: #431 - #333;
}
.box6 {
width: image-width('../img/logo.png');
}
//函数
@std-red: #e4393c;
@light-red: lighten(@std-red, 15%);
@lighter-red: lighten(@std-red, 30%);
@dark-red: darken(@std-red, 15%);
@darker-red: darken(@std-red, 30%);
.box9 {
background: @lighter-red;
border: 1px solid @std-red;
color: @darker-red;
}