可以在我的应用程序中定义主要颜色和辅助颜色(十六进制代码),然后将它们保存到数据库中。
例如,辅助颜色用于链接。我不想说<a href="#" style="color: $fromDatabase">Text</a>
,而是说<a href="#" class=secColor>Text</a>
,其中.secColor
具有类似
.secColor {
color: $fromDatabase;
}
我正在使用Laravel btw。
最佳答案
您可以使用以下代码将.php文件作为CSS包括在内:
index.html:
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="style.php">
</head>
<body>
<!-- stuff goes here -->
</body>
</html>
style.php:
<?php
header("Content-type: text/css");
?>
//DB Query
.secColor{
color: <?php echo $fromDatabase;?>
}
关于php - 从数据库生成CSS类?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39569597/