子目录内没有加载CSS [英] CSS not loading inside sub directory
问题描述
我试图通过index.php从子目录加载css,并定义了一个常量 AMIN_CSS =http:// localhost / gbl_admin / admin_css
。
这个在同一个目录下载入css:
< ; link href =<?php echo ADMIN_PAGE。/ style.css?> type =text / css =stylesheet>
但这个是在子目录中:
< link href =<?php echo ADMIN_PAGE。/ admin_css / style.css?> type =text / css =stylesheet>
//常量decleration
define(SITEURL,'http://'.@$_SERVER ['SERVER_NAME']。/);
define(ADMIN_PAGE,SITEURL。gbl_admin);
define(ADMIN_SCRIPTS,SITEURL。gbl_admin / admin_scripts);
define(ADMIN_CSS,SITEURL。gbl_admin / admin_css);
这个不加载!如何解决这个问题?
您提到的第二个链接被视为
http://localhost/gbl_admin/admin_css/admin_css/style.css a>
您可以看到admin_css重复了两次,因此无法加载CSS文件。因此,正确的网址应如下所示:
http ://localhost/gbl_admin/admin_css/style.css
I am trying to load the css from a sub directory through index.php and have defined a constant AMIN_CSS ="http://localhost/gbl_admin/admin_css"
.
This being in the same directory loads the css:
<link href="<?php echo ADMIN_PAGE."/style.css"?>" type="text/css" rel="stylesheet">
but this one is in the sub directory:
<link href="<?php echo ADMIN_PAGE."/admin_css/style.css"?>" type="text/css" rel="stylesheet">
//constant decleration
define("SITEURL",'http://'.@$_SERVER['SERVER_NAME']."/");
define("ADMIN_PAGE",SITEURL."gbl_admin");
define("ADMIN_SCRIPTS",SITEURL."gbl_admin/admin_scripts");
define("ADMIN_CSS",SITEURL."gbl_admin/admin_css");
This one doesn't load!! How can i solve this?
The second link which you are referring is perceived as
http://localhost/gbl_admin/admin_css/admin_css/style.css
You can see that admin_css is repeated twice hence it is not able to load the CSS File. Hence the correct url should be as follows :
http://localhost/gbl_admin/admin_css/style.css
这篇关于子目录内没有加载CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!