使用 CSS Content: 属性的 Echo php


Echo php using CSS Content: property

我需要使用 css Content: 属性回显 php。

.PHP:

<?php
$links = "<a href='"https://www.facebook.com'" target='"_blank'"><img src='"images/fb.png'"     width='"16'" height='"16'"></a> <a href='"https://twitter.com'" target='"_blank'"><img     src='"images/twitter.png'" width='"16'" height='"16'"></a>";
?>

.CSS:

body li:nth-child(2):after{ 
content: "<?php echo "$links"; ?>";
color:#FFF;
}

.HTML:

<ul>
<li>date</li>
<li>time</li>
</ul>

期望输出:

Date  Time  FB  TW

尝试喜欢

CSS:
body li:nth-child(2):after{ 
    content: "<?php echo $links; ?>";
    color:#FFF;
}

你也可以试试喜欢

content: <?php echo $links; ?>;

假设您的CSSPHP 位于同一文件中

content: "<?php echo $links; ?>";

回显到 CSS 时不需要引号。修改如下:

content: "<?php echo $links; ?>";