Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.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
php文件中的样式表不工作_Php - Fatal编程技术网

php文件中的样式表不工作

php文件中的样式表不工作,php,Php,我有这个php文件,我希望它像样式表一样 <?php header("Content-type: text/css; charset: UTF-8"); a:hover { color: #00B2ED; } .sub-main-menu nav ul li a { color: #00B2ED; } .btn-fc { background: #00B2ED none repeat scroll 0 0; color: #ffffff; display: inline; font

我有这个php文件,我希望它像样式表一样

<?php
header("Content-type: text/css; charset: UTF-8");

a:hover
{
color: #00B2ED;
}
.sub-main-menu nav ul  li a
{
color: #00B2ED;
}
.btn-fc
{
  background: #00B2ED none repeat scroll 0 0;
color: #ffffff;
display: inline;
font-size: 13px;
font-weight: 500;
line-height: 30px;
margin: 0;
padding: 7px 10px;
position: relative;
text-align: center;
text-transform: uppercase;
z-index: 1;

  border: 0; /* remove border   */
  cursor: pointer;

}

?>

我就是这样称呼它的

<link rel="stylesheet" href="user-style.php" />


但内容不会加载。任何风格都不管用。有什么遗漏吗?

这是因为您认为内容不是有效的PHP代码

这里有一个选项可以更改它:

<?php
header("Content-type: text/css; charset: UTF-8");
// the php parser expect to have php code here, but a:hover is not a php code.
// what we can do is just close the php block, and from here its a regular text file
?>
a:hover
{
color: #00B2ED;
}
.sub-main-menu nav ul  li a
{
color: #00B2ED;
}
.btn-fc
{
  background: #00B2ED none repeat scroll 0 0;
color: #ffffff;
display: inline;
font-size: 13px;
font-weight: 500;
line-height: 30px;
margin: 0;
padding: 7px 10px;
position: relative;
text-align: center;
text-transform: uppercase;
z-index: 1;

  border: 0; /* remove border   */
  cursor: pointer;

}

a:悬停
{
颜色:#00B2ED;
}
.子主菜单nav ul li a
{
颜色:#00B2ED;
}
.btn fc
{
背景:#00B2ED无重复滚动0;
颜色:#ffffff;
显示:内联;
字体大小:13px;
字号:500;
线高:30px;
保证金:0;
填充:7px 10px;
位置:相对位置;
文本对齐:居中;
文本转换:大写;
z指数:1;
边框:0;/*删除边框*/
光标:指针;
}
另外-注意里面的解释(在评论中)


为什么您需要.css文件作为.php???Batsy,我将存储用户首选的配色方案,这就是为什么它被命名为user style,您不能将css包装在其中。标头()不是必需的。子主菜单nav ul li a{color:}代替。啊!谢谢你指出!我的懒惰,但还是要谢谢你:)