[英]How to include css in html using php
我包括使用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代碼添加到CSS文件style.css
並用PHP回顯HTML <link>
。
<?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>'
;?>
您必須將CSS與標記一起使用。
<style>
<?php
include 'css/cssnew.css';
?>
</style>
您還可以使用HTML標簽。
<?php
echo '<link href="css/cssnew.css" rel="stylesheet">';
?>
如您的評論所述,您可以將以下PHP代碼另存為newcss.php
<?php echo '<link href="css/cssnew.css" rel="stylesheet">'; ?>
現在,動態地將PHP文件包含為
<?php
include 'newcss.php';
?>
嘗試如下
內部HTML
<link rel="stylesheet" href="css/cssnew.css" type="text/css">
內部PHP
<?php echo '<link href="css/cssnew.css" rel="stylesheet" type="text/css" >'; ?>
好吧,我看到了這兩個選擇。 希望對您有所幫助。
<?php echo '<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">'; ?> <!-- or --> <style><? include_once ”PATH/your_style.css" media ="" ?></style> // <style><? require_once ”PATH/your_style.css" media ="" ?></style> <!--Good Luck I hope it helps!-->
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.