我使用 php 包含 css 就像
<?php include "css/cssnew.css"; ?>
但是 Font Awesome 不起作用,图标显示为正方形
CSS:
@font-face {
font-family: FontAwesome;
src: url(/css/fonts/fontawesome-webfont);
font-weight: 400;
font-style: normal
}
.fa {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale
}
.fa-angle-double-up:before {
content: '\f102';
}
谁能告诉我为什么 fa-angle-double-up:before 没有显示
content: '\f102';
最佳答案
我知道,有 3 种方法可以将 CSS 添加到 HTML 并使用 PHP 进行回显:
- 使用链接:
<?php echo '<link rel="stylesheet" type="text/css" href="style.css" media="screen" />';
在此方法中,您可以在 CSS 文件 style.css
中添加 CSS 代码。并回显 HTML <link>
使用 PHP。
- 将 CSS 嵌入 HTML:
<?php echo '<style media="screen" type="text/css">Add style rules here</style>'; ?>
示例:
<?php echo '<style media="screen" type="text/css">@font-face{font-family:FontAwesome;src:url(/css/fonts/fontawesome-webfont);font-weight:400;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-angle-double-up:before{content:"\f102"}</style>'; ?>
- 最后一个方法:
<style><?php include "css/cssnew.css"; ?></style>
或者
<?php
echo '<style>';
include "css/cssnew.css";
echo '</style>'
;?>
关于php - 如何使用php在html中包含css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46150220/