LESS中&符号

用法:&符号有2中用法,其一:父选择符;其二:且的意思

其一:父选择符

.ant-menu{
  background: #fff; 
  border-bottom:0;

  .ant-menu-item{
      color: rgba(0,0,0,0.65);  
      padding-left:16px; 
      padding-right:16px;
        &:hover {
                color: #235FB8; border-bottom-color:transparent;
            }
  }

  .ant-menu-submenu &{
     border-color: #235FB8;
  }

}

 转化为CSS效果:

.ant-menu {
  background: #fff;
  border-bottom: 0;
}
.ant-menu .ant-menu-item {
  color: rgba(0,0,0,0.65);
  padding-left: 16px;
  padding-right: 16px;
}
.ant-menu .ant-menu-item:hover {
  color: #235FB8;
  border-bottom-color: transparent;
}
.ant-menu-submenu .ant-menu {
  border-color: #235FB8;
}

 &符号放在类后面

.ant-menu{
  background: #fff; 
  border-bottom:0;

  .ant-menu-item{
      color: rgba(0,0,0,0.65);  
      padding-left:16px; 
      padding-right:16px;
  }

  .ant-menu-submenu &{
     border-color: #235FB8;
  }

}

转为为CSS效果: 

.ant-menu {
  background: #fff;
  border-bottom: 0;
}
.ant-menu .ant-menu-item {
  color: rgba(0,0,0,0.65);
  padding-left: 16px;
  padding-right: 16px;
}
.ant-menu-submenu .ant-menu {
  border-color: #235FB8;
}

 

其二:且

.ant-menu{
  background: #fff; 
  border-bottom:0;

  .ant-menu-item{
      color: rgba(0,0,0,0.65);  
      padding-left:16px; 
      padding-right:16px;
  }

  &.ant-menu-submenu{
     border-color: #235FB8;
  }

}

转化为CSS的效果: .ant-menu.ant-menu-submenu与.ant-menu .ant-menu-submenu不一样,前者是同级,后者是父子关系

.ant-menu {
  background: #fff;
  border-bottom: 0;
}
.ant-menu .ant-menu-item {
  color: rgba(0,0,0,0.65);
  padding-left: 16px;
  padding-right: 16px;
}
.ant-menu.ant-menu-submenu {
  border-color: #235FB8;
}

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值