Trying to concatenate Sass variable and a string

坚强是说给别人听的谎言 提交于 2019-12-10 10:30:35

问题


I'm trying to concatenate a Sass variable with a string. How do I do it?

Below there is a code example.

@mixin setIcons($pathImages:$pathImages, $extensionIcon:$extensionIcon {
   @each $class-icon in $class-icons-30 {
     .snw-tui-icon-#{$class-icon} {
       @include icon($class-icon, $pathImages, $extensionIcon, 30px);
   }
     .snw-tui-icon-**#{$class-icon} + "selected"** {
       @include icon(**$class-icon + "selected"**, $pathImages, $extensionIcon, 30px);
  }
}

回答1:


You want to interpolate.

$sidebar-width: 20px;

.target {
     width: calc(100% - #{$sidebar-width});
}

Hope this helps

More info into it here: https://webdesign.tutsplus.com/tutorials/all-you-ever-need-to-know-about-sass-interpolation--cms-21375




回答2:


For a font variable, this is what worked for me:

$font-family-sans-serif:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" !default;
$font-family-custom: 'My Custom Font', #{$font-family-sans-serif}

Good Luck



来源:https://stackoverflow.com/questions/42364017/trying-to-concatenate-sass-variable-and-a-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!