在Sass中使用冒号语法和变量 [英] Using colon syntax and variables in Sass
问题描述
我仍在使用旧的冒号语法(我更喜欢它而不是 括号语法)和以下特定代码:
I am still using the old colon syntax (I prefer it more than the bracket syntax) and this particular code:
a.button-link
+box($main-color)
+border-radius(5px)
:background
:color $main-color
:color #fff
:padding 5px
生成如下警告:
不建议使用警告: 在第12行,'/Users/eumir/rails_apps/dxconnect/app/ stylesheets/partials/utilities/_link-styles.sass' 用=设置属性已被弃用,并将在 版本3.2. 使用"background:$ main-color"代替.
DEPRECATION WARNING: On line 12, character 3 of '/Users/eumir/rails_apps/dxconnect/app/ stylesheets/partials/utilities/_link-styles.sass' Setting properties with = has been deprecated and will be removed in version 3.2. Use "background: $main-color" instead.
我尝试过,但是我的背景色仍然没有显示.任何帮助 对此吗?谢谢!
I tried that but my background color still doesn't show up. Any help on this please? Thanks!
推荐答案
这是我从Haml小组获得的有效答案.显然,我将变量声明为$ main-color:#f00",而不仅仅是$ main-color:#f00
Here's a working answer I got from the Haml groups. Apparently I declared my variable as $main-color: "#f00" instead of just $main-color: #f00
您的$ main-color变量不应该带有引号.在Sass 3中,所有变量 和mixin参数应与您希望它们出现在CSS中一样, 没有任何额外的报价. "
"Your $main-color variable shouldn't have quotes. In Sass 3, all variables and mixin arguments should be just as you want them to appear in the CSS, without any extra quotes. "
这篇关于在Sass中使用冒号语法和变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!