Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在不刷新页面的情况下从PHPVAR呈现css代码?_Php_Css_Ajax - Fatal编程技术网

如何在不刷新页面的情况下从PHPVAR呈现css代码?

如何在不刷新页面的情况下从PHPVAR呈现css代码?,php,css,ajax,Php,Css,Ajax,我有一个页面,所有内容都是用ajax和php完成的 我有在标签内容,用户可以选择颜色选择器的颜色 当用户选择保存颜色时,我将新的CSS代码存储到数据库中 下面是CSS代码 .browser_content{ background-color: #188072; width: 420px; padding-left: 5px; color: #FFFFFF; -moz-border-radius: 5px; border-radius: 5px; webkit-border-radius: 5px

我有一个页面,所有内容都是用ajax和php完成的

我有在标签内容,用户可以选择颜色选择器的颜色

当用户选择保存颜色时,我将新的CSS代码存储到数据库中

下面是CSS代码

.browser_content{ background-color: #188072; width: 420px; padding-left: 5px; color: #FFFFFF; -moz-border-radius: 5px; border-radius: 5px; webkit-border-radius: 5px; background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#188072), to(#333333)); background: -webkit-linear-gradient(top, #188072, #333333); background: -moz-linear-gradient(top, #188072, #333333); background: -ms-linear-gradient(top, #188072, #333333); background: -o-linear-gradient(top, #188072, #333333); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#188072, endColorstr=#333333); } 


.hotel_location{ background-color: #999999; } 
所以,当用户下次尝试打开此选项卡时,我想将此css加载到该页面中。我尝试使用php头文件,但什么也没发生

我必须再次注意,没有页面刷新,内容是用ajax加载的,也不可能有像.css这样的新php文件,必须使用echo、print或类似的方法来解决


谢谢。

您可以在php页面中使用类似的内容:

<style type="text/css">
.your_class
{
<?php
    $colorValues = ... // get user's color settings from db
    echo '    color: ' . $colorValue  . ' !important;'
?>
}
</style>;
看看这个:

请显示您用于输出自定义CSTO添加到此答案的实际代码,如果不明显,您可以创建一个php脚本,返回带有正确标题的样式表内容,并在Ayman链接的JS中使用其url。