[英]Dynamic Data in Eksternal CSS
我有一个文件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;
}
我想更改徽标,但如何在eksternal CSS中添加动态数据php,
我尝试这样,但不起作用:(
<?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文件。 因此,您必须在head标记内的.php文件中执行以下操作
<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);
?>
它将为您替换徽标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.