[英]Dynamic Data in Eksternal CSS
I have a file eksternal css " style.css " 我有一个文件eksternal css“ style.css ”
<link rel="stylesheet" type="text/css" id="theme" href="css/style.css"/>
this part code is 这部分代码是
.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;
}
i want to change logo, but how to add dynamic data php in eksternal css, 我想更改徽标,但如何在eksternal CSS中添加动态数据php,
i try like this, but doesn't work :( 我尝试这样,但不起作用:(
<?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;
}
Have a solution ?? 有解决方案吗? Help me thank's
帮帮我谢谢
Php doesn't work in a .css file. PHP在.css文件中不起作用。 It only works in .php file.
它仅适用于.php文件。 So you have to do the following in the .php file within the head tag
因此,您必须在head标记内的.php文件中执行以下操作
<style>
background: url("../img/<?php echo $web->logo ?>") top center no-repeat #68A9CF;
</style>
and please use the code at the first of the file to initiate the webroot. 并请使用文件开头的代码来启动webroot。
<?php
include "connection.php";
$dataweb = mysqli_query($con,"select logo from web");
$web = mysqli_feth_object($dataweb);
?>
It will replace the logo for you. 它将为您替换徽标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.