我有一个文件eksternal css "style.css"
<link rel="stylesheet" type="text/css" id="theme" href="css/style.css"/>
此部分代码为
.x-navigation > li.xn-logo > a:first-child {
font-size: 0px;
text-indent: -9999px;
background: url("../img/logo.png") top center no-repeat #68A9CF;
padding: 0px;
border-bottom: 0px;
color: #FFF;
height: 60px;
background-size: 180px 50px;
}
我想改变标志,但如何添加动态数据PHP在eksternal css,
我尝试这样做,但不工作:(
<?php
include "connection.php";
$dataweb = mysqli_query($con,"select logo from web");
$web = mysqli_feth_object($dataweb);
?>
.x-navigation > li.xn-logo > a:first-child {
font-size: 0px;
text-indent: -9999px;
background: url("../img/<?php echo $web->logo ?>") top center no-repeat #68A9CF;
padding: 0px;
border-bottom: 0px;
color: #FFF;
height: 60px;
background-size: 180px 50px;
}
有解决方案吗??
Php不能在。css文件中工作。它只适用于。php文件。所以你需要在。php文件中head标签
中做以下操作<style>
background: url("../img/<?php echo $web->logo ?>") top center no-repeat #68A9CF;
</style>
,请使用文件开头的代码来启动webroot。
<?php
include "connection.php";
$dataweb = mysqli_query($con,"select logo from web");
$web = mysqli_feth_object($dataweb);
?>