[英]How to include css in html using php
I'm including css using php like 我包括使用PHP的CSS像
<?php include "css/cssnew.css"; ?>
But Font Awesome not working, icons showing as squares 但是Font Awesome无法正常工作,图标显示为正方形
css: 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';
}
Can anyone please tell me why that fa-angle-double-up:before is not showing 谁能告诉我为什么fa-angle-double-up:before不显示
content: '\f102';
I know, there are 3 method for adding CSS to HTML and echo with PHP: 我知道,有3种方法可以将CSS添加到HTML并通过PHP进行回显:
<?php echo '<link rel="stylesheet" type="text/css" href="style.css" media="screen" />';
In this method, you can add your CSS codes in CSS file style.css
and echo HTML <link>
with PHP. 在这种方法中,您可以将CSS代码添加到CSS文件
style.css
并用PHP回显HTML <link>
。
<?php echo '<style media="screen" type="text/css">Add style rules here</style>'; ?>
Example: 例:
<?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>
Or 要么
<?php
echo '<style>';
include "css/cssnew.css";
echo '</style>'
;?>
You have to use CSS with tag. 您必须将CSS与标记一起使用。
<style>
<?php
include 'css/cssnew.css';
?>
</style>
you can also use HTML tag. 您还可以使用HTML标签。
<?php
echo '<link href="css/cssnew.css" rel="stylesheet">';
?>
As your comment says, You can save below php code as newcss.php 如您的评论所述,您可以将以下PHP代码另存为newcss.php
<?php echo '<link href="css/cssnew.css" rel="stylesheet">'; ?>
Now dynamically include in your PHP file as 现在,动态地将PHP文件包含为
<?php
include 'newcss.php';
?>
Try like below 尝试如下
Inside HTML
内部HTML
<link rel="stylesheet" href="css/cssnew.css" type="text/css">
Inside Php
内部PHP
<?php echo '<link href="css/cssnew.css" rel="stylesheet" type="text/css" >'; ?>
Well I saw this two options. 好吧,我看到了这两个选择。 I hope it helps.
希望对您有所帮助。
<?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.