【发布时间】:2016-05-17 10:36:31
【问题描述】:
我有一个 style.css:
<link href="/file.css" rel="stylesheet" type="text/css" property='stylesheet'/>
#menu{
background:red; //file.css content
}
然后是一个 php:
<link rel='stylesheet' type='text/css' href='/color.php' />
//color.php content:
header("Content-type: text/css", true);
include_once("mysqli.php");
session_start();
$userid=$_SESSION['id'];
$stmt = $mysqli_link->prepare("SELECT site FROM cores where user=? limit 1");
$stmt->bind_param('i', $userid);
$stmt->execute();
$stmt->bind_result($color);
$stmt->fetch();
$stmt->close();
if($color=="blue"){
$m="blue";
}
else if($color=="green"){
$m="green";
}
echo"
#menu{
background-color:$m;
}
";
如果我打开 color.php,它会很好地打印颜色。但在页面中它不会覆盖 style.css #menu 红色。怎么了?有什么帮助吗?
谢谢朋友们!
【问题讨论】:
-
你检查过$m的值来确认它不是空的吗?
-
@farooqaaa 如果我在浏览器中打开 color.php 它会显示 #menu{ background-color:blue; } 但在我的页面中它不是蓝色的......