Using colon syntax and variables in Sass

馋奶兔 提交于 2019-12-12 03:49:17

问题


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 

generates a warning like so:

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!


回答1:


Try:

a.button-link
  background: $main-color

or

a.button-link
  background-color: $main-color



回答2:


Even if you prefer the SASS syntax instead of SCSS (I do too!), you should update your files using the converter:

sass-convert --from=sass2 --to=sass --recursive views/stylesheets

See sass-convert --help for all the options options.




回答3:


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

"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. "



来源:https://stackoverflow.com/questions/3062241/using-colon-syntax-and-variables-in-sass

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