Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.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
使用sass/css交换颜色和背景色_Css_Sass - Fatal编程技术网

使用sass/css交换颜色和背景色

使用sass/css交换颜色和背景色,css,sass,Css,Sass,对于一个有响应性的布局,我试图在特定的场合将颜色与背景色切换,反之亦然 使用sass时,交换颜色和背景色值的最干净方法是什么?纯CSS在这种情况下不起作用,是吗 差不多 p { @media … { [swap currentTextColor and currentBgColor] } } 您可以创建一个mixin: @mixin swapColors($textColor, $bgColor) { background-color: $bgColor; color: $textCo

对于一个有响应性的布局,我试图在特定的场合将颜色与背景色切换,反之亦然

使用sass时,交换颜色和背景色值的最干净方法是什么?纯CSS在这种情况下不起作用,是吗

差不多

p {
@media … {
[swap currentTextColor and currentBgColor]
}
}

您可以创建一个mixin:

@mixin swapColors($textColor, $bgColor) {
  background-color: $bgColor;
  color: $textColor;

  @media ... {
    background-color: $textColor;
    color: $bgColor;
  } 
}

.tree {
  @include swapMobile(red, black);
}
除此之外,我不知道任何内置的东西可以做这样的事情