一、less
<div class="box1"></div>
<div class="box2"></div>
<div class="box3">今天中午吃什么</div>
<div class="box4">
<div>渔粉</div>
<p><a href="">原味</a></p>
</div>
<div class="box5">
<div class="box6"></div>
</div>
<div class="box7">传参数</div>
<div class="box8">带值</div>
<div class="box9"></div>
<div class="box10"></div>
<div class="box11"></div>
<div class="box12"></div>
@mywidth: 100px;
@mycolor: pink;
@mymargin:10px;
.box1 {
width: 100px;
height: 100px;
background-color: @mycolor ;
}
.box2 {
width: @mywidth;
height: @mywidth;
background-color: @mycolor ;
}
.box3 {
@font-size: 30px;
font-size: @font-size ;
}
.box4 {
width: @mywidth;
height: @mywidth;
background-color: green;
div {
width: 50px;
height: 50px;
background-color: @mycolor ;
}
a {
text-decoration: line-through;
}
}
.border {
border: 3px dotted;
}
.box6 {
width: 50px;
height: 50px;
.border;
}
.common(@radius,@padding,@size,@color){
border-radius:@radius ;
padding:@padding ;
font-size:@size ;
color: @color;
}
.box7{
width: @mywidth;
height: @mywidth;
background-color: @mycolor ;
.common(50%, 20px,30px, green);
}
.common1(@radius,@padding,@size,@color:pink){
border-radius:@radius ;
padding:@padding ;
font-size:@size ;
color: @color;
}
.box8{
width: @mywidth;
height: @mywidth;
background-color: green ;
.common1(50%,20px,30px);
}
.box9{
width: @mywidth+20px;
height: @mywidth;
background-color: @mycolor ;
margin: @mymargin;
}
.box10{
width: @mywidth*3;
height: @mywidth;
background-color: @mycolor ;
margin: @mymargin;
}
.box11{
width: @mywidth - 20px;
height: @mywidth;
background-color: @mycolor ;
margin: @mymargin;
}
.box12{
width: (@mywidth/2);
height: @mywidth;
background-color: @mycolor ;
margin: @mymargin;
}
二、scss
<div class="box1"></div>
<div class="box2"></div>
<button>点餐</button>
<div class="box3">脑瓜疼</div>
<div class="box4"></div>
$mycolor:pink !default;
$margin:20px 0;
.box1 {
width: 100px;
height: 100px;
background-color: $mycolor;
}
$mycolor:green;
.box2 {
width: 100px;
height: 100px;
background-color: $mycolor;
margin: $margin;
}
@mixin border-radius {
border-radius: 10%;
}
button {
@include border-radius;
font-size: 30px;
}
@mixin center($width, $height) {
width: $width;
height: $height;
}
.centerBox {
@include center(500px, 250px);
}
.common {
border: 1px solid #ccc;
padding: 5px 10px;
font-size: 20px;
}
.box3 {
width: 100px;
height: 100px;
background: $mycolor;
color: white;
@extend .common;
}
%bianju {
margin-top: 5px;
padding-top: 5px;
}
.size {
width: 100px;
height: 100px;
}
.box4 {
@extend .size ;
background-color: $mycolor;
@extend %bianju;
}