我有一个小问题。我可以通过这种方式动态更改(使用 php)css 样式的内容吗?
<?php
header("Content-type: text/css; charset: UTF-8");
$color = "red;";
?>
header {
color:<?php print $color; ?>
}
?>
最佳答案
当然有可能,为什么不试一试呢?
在 HTML 中链接 php css:
<link rel="stylesheet" type="text/css" href="css/name-of-file.css.php">
并在您的 css.php 文件中放入您的代码,但没有
<style type="text/css">
应该是这样的
<?php
header("Content-type: text/css; charset: UTF-8");
$color = "red;";
?>
header {
color:<?php print $color; ?>
}
关于php - 在 php 中动态更改 css?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19209721/