gpt4 book ai didi

css - 减少带有可选参数的混合

转载 作者:行者123 更新时间:2023-11-28 06:58:19 25 4
gpt4 key购买 nike

我有一个 Less 混合定义为:

.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);

@weight@style@color

使用默认值

最佳答案

要提供参数字符串最下方的参数,您还必须提供它要定义的预期变量。所以这个:

.fontStyle('NimbusSansNovCon-Reg', 12px, @letter-spacing: 0.1em);

生成这个(注意 colorfont-weightfont-style 如何使用默认值):

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

关于css - 减少带有可选参数的混合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33374887/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com