less使用

  • 把一些需要统一的样式写到mixin.less中,利用混入特性共用。设计时将需要chong’du的样式摘取出来。以下一些示例:
// 字体
.font(@size, @color){
  font-size: @size;
	color: @color;
}

// 宽高 
.wh(@width, @height, @color){
	width: @width;
	height: @height;
  color: @color
}
  • 对于功能性的css可以提前封装好,然后去用,比如居中,布局等
// flex布局
.flex_layout(@type: space-between){
	display: flex;
	justify-content: @type;
}

// Tdesign命名非常清楚
.horizontal-vertical-center-with-flex() {
  display: flex;
  align-items: center;
  justify-content: center;
}

// 有宽高的盒子上下左右居中
.center(@width, @height) {  
	position: absolute;
	top: 50%;
    left: 50%;
    margin-top: -@height/2;
    margin-left: -@width/2;
}

// 无宽高盒子上下左右居中
.center_noWH(@width, @height) {  
	display: flex;
  align-items: center;
  justify-content: center;
}
  • 利用less写出具有层级结构的css, 父选择器可以与伪类结合起来使用
.header {
  .p {
    color: red
  }
  &:hover {
    color: green
  }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值