为什么我的CSS / PHP样式表没有应用到我的网站?

时间:2013-05-24 13:47:39

标签: php css

我正在使用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 没有被应用到我的网页!
有人可以告诉我,我在这里做错了吗?

你可以看到我的 PAGE HERE

它应该在右侧显示一个侧边栏而在左侧显示另一个侧边栏但是它不起作用(但奇怪的是,我的LOCALL机器上的代码正在运行)。

2 个答案:

答案 0 :(得分:3)

您的文件无效CSS。尝试删除评论的PHP块 - 我怀疑你会发现它有效!

答案 1 :(得分:0)

浏览器大量缓存css文件。

要么在css或缓存中发送过期标头css include ...基本上每次请求时都会更改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(); ?>">