css – 使用可选参数减少混音

我有一个Less mixin定义为:
.fontStyle(@family,@size,@weight: normal,@style: normal,@color: #ffffff,@letter-spacing: normal) {
  font-family: @family;
  font-size: @size;
  color: @color;
  font-weight: @weight;
  font-style: @style;
 letter-spacing: @letter-spacing;
}

如何定义使用方法

.fontStyle('NimbusSansNovCon-Reg',12px,0.1em);

I.E.使用@weight,@style,@color的认设置

解决方法

要提供一个远远低于参数字符串的参数,您还必须提供要定义的预期变量.所以这:
.fontStyle('NimbusSansNovCon-Reg',@letter-spacing: 0.1em);

产生这个(注意颜色,字体重量和字体样式使用的认值):

font-family: 'NimbusSansNovCon-Reg';
font-size: 12px;
color: #ffffff;
font-weight: normal;
font-style: normal;
letter-spacing: 0.1em;

相关文章

Css3如何实现鼠标移上变长特效?(图文+视频)
css3怎么实现鼠标悬停图片时缓慢变大效果?(图文+视频)
jquery如何实现点击网页回到顶部效果?(图文+视频)
css3边框阴影效果怎么做?(图文+视频)
css怎么实现圆角边框和圆形效果?(图文+视频教程)
Css3如何实现旋转移动动画特效