less中&的用法

less中的&有两种用法:

1、并且关系

.box1{
    
    
	.box2{
    
    }
	&.box3{
    
    }
}

等价于:

.box1{
    
    }
.box1 .box2{
    
    } //父子关系
.box1.box3{
    
    } //并且关系

2、父子关系转换

.box1{
	.box2{}
	.box3 &{}
}

等价于:

.box1{
    
    }
.box1 .box2{
    
    }//父子关系
.box3 .box1{
    
    }//父子关系转变

猜你喜欢

转载自blog.csdn.net/jiangjunyuan168/article/details/126611900