我的PHP样式表使用以下(简化)代码
<?php header("Content-type: text/css; charset: UTF-8"); ?>
/* Our dynamic styles go here */
/* We will check BOTH sidebars are there so we can adjust width of our content */
<?php if ( is_active_sidebar('secondary') && is_active_sidebar('main') ) {
?>
#blogs{
float: right;
width: 530px;
}
<?php } ?>
现在,当我查看我的网页的来源,我得到这个(完全应该):
<link rel="stylesheet" type="text/css" media="all" href="http://www.mypage.com/wordpressdevelopment/wp-content/themes/Endless_Theme/functions/dynamic_css.php">
所以当我点击我上面的链接(Endless_Theme/functions/dynamic_css.php
)我得到这样的输出(所以现在我知道我的PHP/CSS脚本正在工作):
/* Our dynamic styles go here */
/* We will check BOTH sidebars are there so we can adjust width of our content */
#blogs{
float: right;
width: 530px;
}
但问题是,我的CSS/PHP是不应用到我的网页!谁能告诉我,我在这里做错了什么?
你可以看到我的页在这里
它应该显示一个侧边栏在右侧和另一个在左侧,但它不工作(但奇怪的是,相同的代码是在我的本机工作)。
你的文件不是有效的CSS。试着删掉PHP的注释块——我想你会发现它可以工作的!
浏览器大量缓存css文件。
在css中发送一个过期头或缓存失败的css包含…基本上每次请求时都更改url,这样浏览器就会将其视为新资产。
<link rel="stylesheet" type="text/css" media="all" href="http://www.mypage.com/wordpressdevelopment/wp-content/themes/Endless_Theme/functions/dynamic_css.php?cb=<?= time(); ?>">