【发布时间】:2017-05-17 20:24:17
【问题描述】:
我按照本教程https://css-tricks.com/css-variables-with-php/ 在 CSS 中使用 php 变量。我正在使用具体 5(5.6 版)CMS。 我加载了 .php 和 .css 文件。
新文件.php
<?php
header("Content-type: text/css; charset: UTF-8");
$clRed = 'red';
?>
NewFile.css
@import "/path/css/NewFile.php?type=cms";
.one-third{
width: 33%;
margin: 0 auto;
background: <?php echo $clRed;?>;
}
但是 css 没有读取 php 变量。
我也参考了这些链接
http://doctype.com/use-php-variables-inside-css-file
how can I use of a php variable into a .css file
PHP Variables in CSS not working
提前致谢。 注意:我知道这不是推荐的做法。
【问题讨论】: