Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.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 使用mixin';s_Css_Sass - Fatal编程技术网

Css 使用mixin';s

Css 使用mixin';s,css,sass,Css,Sass,我目前正在使用此mixin: @mixin isMobile() { html[data-browser*="Mobile"] & { @content; } } 我想用这个mixin有条件地应用于一个变量,如下所示: $div-height: 20px; @include isMobile() { $div-height: 10px; } 我知道这不是正确的方法,我也尝试过下面的方法,但没有成功。我怎样才能正确地尝试这个条件?谢谢 @if (html[data-

我目前正在使用此mixin:

@mixin isMobile() {
  html[data-browser*="Mobile"] & {
    @content;
  }
}
我想用这个mixin有条件地应用于一个变量,如下所示:

$div-height: 20px;
@include isMobile() {
  $div-height: 10px;
}
我知道这不是正确的方法,我也尝试过下面的方法,但没有成功。我怎样才能正确地尝试这个条件?谢谢

@if (html[data-browser*="Mobile"]) {
  $div-height: 20px;
} @else {
  $div-height: 10px;
};

条件部分必须在mixin本身中

@mixin isMobile($type) {
  $div-height: 0;
  html[data-browser*="Mobile"] {
    @if($type == 'A'){
      $div-height: 20px;
    }
    @else{
      $div-height: 10px;
    }
    height: $div-height;
    @content;
  }
}


@include isMobile('B'){
  color:black;
}


/*Output*/
html[data-browser*="Mobile"] {
  height: 10px;
  color: black;
}

你能解释一下这句话吗<代码>html[数据浏览器*=“手机”]&{