我有一个布局文件,它被加载到多个路由上。在我的布局文件中,我加载CSS:
<link rel="stylesheet" type="text/css" href="css/app.css" media="screen" />这会正确地从https://myurl.com/css/app.css加载我的文件
然而,这只在访问我的应用程序的基本路径"/“时有效。例如,如果用户访问/user,那么我最终会访问https://myurl.com/user/css/app.css
如何在模板和布局中正确引用静态CSS路径?
发布于 2016-09-19 10:36:05
要加载相对于站点根目录的CSS文件,只需在href前面加上/
<link rel="stylesheet" type="text/css" href="/css/app.css" media="screen" />https://stackoverflow.com/questions/39564545
复制相似问题