Does SASS support inline IF statements?

浪子不回头ぞ 提交于 2019-12-18 04:34:07

问题


I'd like to set a SASS variable using inline IF's similar to how its done in PHP or Javascript

Is something like this possible?

$myVar: ($something >= 10 ? true : false);

I'm aware of @if control directives but I want to use a shorter inline syntax.


回答1:


Sass does support of conditional (ternary) operator or one line if statement as it works in languages like Javascript or PHP.

$variable: if(condition, result-when-true, result-when-false);

Article about improved if and what's new in Sass 3.3.
P.S. Before Sass 3.3 it did not work as it should. Issue in Sass repo.



来源:https://stackoverflow.com/questions/25300453/does-sass-support-inline-if-statements

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