首页 / CSS / 用scssphp更改scss变量
用scssphp更改scss变量
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了用scssphp更改scss变量,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1303字,纯文字阅读大概需要2分钟。
内容图文
![用scssphp更改scss变量](/upload/InfoBanner/zyjiaocheng/663/13418a85de974d3d998479d5fc27148e.jpg)
我正在使用scssphp来查看是否可以使用它来更改在现有的scss中设置的变量,因此我设置了一个测试用例:
require_once "scssphp-0.1.7/scss.inc.php";
use Leafo\ScssPhp\Compiler;
use Leafo\ScssPhp\Server;
$scss = new Compiler();
$scss->addImportPath('testsass');
$scss->compile('$color: blue;');
$test = $scss->compile('@import "test.scss"');
echo $test;
我的test.scss看起来像:
$color: red;
body {
background: $color;
}
现在我希望我可以在$php中将$color更改为blue,然后进行编译,并且我确定上面显示的方式不正确.
但是,有一种方法可以将$color的变量更改为blue,而不是重新编译test.scss?
解决方法:
我自己用完美无缺的解决方法来回答这个问题.
我用所有变量创建了一个config.scss.并决定在编译导入config.scss的layout.scss之前打开并重写它
require_once "scssphp-0.1.7/scss.inc.php";
use Leafo\ScssPhp\Compiler;
use Leafo\ScssPhp\Server;
$scss = new Compiler();
$scss->setImportPaths('sass');
//$txt = '$color: yellow;';
$txt = '$font: "Open sans";';
$txt .= '$body-font-size: 15px;';
$txt .= '$containerWidth: 1140px;';
$txt .= '$gutter-size: 15px;';
$txt .= '$primarycolor: red;';
$txt .= '$secondarycolor: blue;';
$txt .= '$background: #e8e3e3;';
$txt .= '$textcolor: $primarycolor;';
$txt .= '$linkcolor: #000;';
$file = fopen('sass/_configuratie.scss', "w");
if (fwrite($file, $txt)) {
$server = new Server('sass', null, $scss);
$server->serve();
}
内容总结
以上是互联网集市为您收集整理的用scssphp更改scss变量全部内容,希望文章能够帮你解决用scssphp更改scss变量所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。