Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 减少混音建议_Css_Less - Fatal编程技术网

Css 减少混音建议

Css 减少混音建议,css,less,Css,Less,我正在尝试为我的字体大小和行高创建一个较小的混合,但目前在尝试运行时出现了一个错误。有谁能告诉我这方面可能会出什么问题: .font( @size: 1.6, @line: @size * 1.5 ){ @fontSizeRem: @size; @fontSizePx: ( @size * 10 ); @lineHeightRem: @line; @lineHeightPx: ( @line * 10 ); font-size: ~"@{fontSizePx}px"; f

我正在尝试为我的字体大小和行高创建一个较小的混合,但目前在尝试运行时出现了一个错误。有谁能告诉我这方面可能会出什么问题:

.font( @size: 1.6, @line: @size * 1.5 ){
  @fontSizeRem: @size;
  @fontSizePx: ( @size * 10 );
  @lineHeightRem: @line;
  @lineHeightPx: ( @line * 10 );
  font-size: ~"@{fontSizePx}px";
  font-size: ~"@{fontSizeRem}rem";
  line-height: ~"@{lineHeightPx}px";
  line-height: ~"@{lineHeightRem}rem";
}

h1{
 .font(1.6);
}

LESS不支持依赖于其他参数的参数。要实现可选的第二个参数,可以添加另一个mixin:

.font( @size:1.6 ) {
  .font(@size, @size * 1.5)
}
.font( @size, @line ) {
    /* ... See question for the remainder ... */
汇编至:

h1 {
  font-size: 16px;
  font-size: 1.6rem;
  line-height: 24.000000000000004px;
  line-height: 2.4000000000000004rem;
}