我使用的是php
语言。在我的数据库中有正常图像和悬停图像。我知道如何从数据库中调用它,但我不知道如何创建类,以便如果我的数据库中有两个条目,即每个正常图像和悬停图像,并通过从db调用它将充当2带有悬停图片的按钮图片,因为我的rows
column
我在头部之间定义了它。
<style>
.n1{background:url(../images/no.png);
width:110px; height:29px;
float:left;
margin-top:6px
}
.n1:hover{
background:url(../images/no-h.png);
}
</style>
答案 0 :(得分:0)
如果您使用的是内联样式,那么您可以使用它:
<?php $var = 'no'; ?>
<style>
.n1{background:url(../images/<?php echo $var ?>.png);
width:110px; height:29px;
float:left;
margin-top:6px
}
.n1:hover{
background:url(../images/<?php echo $var ?>-h.png);
}
</style>
答案 1 :(得分:0)
您可以使用以下
创建动态CSSDefine Content-Type on the top of your .css.php file:
<?
header('Content-Type: text/css');
// print out your php-driven css...
?>
and call the file like this ..
<link rel="stylesheet" type="text/css" media="screen" href="CSS_PATH/name-of-file.css.php">