3

我正在使用一种php语言。在我的数据库中有普通图像和悬停图像。我知道如何从数据库中调用它,但我不知道如何创建类,这样如果我的数据库中有 2 个条目用于每个即普通图像和悬停图像,并且通过从数据库调用它,它将充当 2带有悬停图像的按钮图像,因为我有 2rowscolumn

我在 head 之间定义了它。

<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>
4

2 回答 2

0

您可以使用以下内容创建动态 CSS

Define 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">
于 2013-11-14T10:22:21.813 回答
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>
于 2013-11-14T10:00:13.130 回答