将HTML移至其他文件夹,现在无法正确链接CSS [英] Moved HTML into a different folder, now it's not linking CSS correctly

查看:65
本文介绍了将HTML移至其他文件夹,现在无法正确链接CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个标头(header.html)文件,该文件将导入到我网站上的其他页面中.当我仅将其放在WebContent文件夹中时,它可以工作,并且可以完美地从Assets文件夹中绘制CSS文件,字体和图像.但是,当我尝试使用

I created a header (header.html) file to be imported into different pages on my site. It works when I have it only in the WebContent folder, and draws the CSS files, fonts, and images from the Assets folder perfectly. However when I try to import it into a JSP page under the User folder using this method, it doesn't work.

当我将header.html移到User文件夹时,它完全停止了Assets文件夹中的绘图,并且标题只是文本.我通过以下方式链接它:

When I move header.html into the User folder, it stops drawing from the Assets folder altogether, and the header just becomes text. I am linking it by:

<link rel="stylesheet" type="text/css" href="assets/css/custom.css">

此外,用户"文件夹和资产"文件夹都直接位于WebContent下.

Also, the User folder and Assets folder are both directly under WebContent.

提前谢谢!

推荐答案

只要在父目录中更改文件夹结构即可同时拥有上面提到的用户和资产

providing the folder structure has both user and assets mentioned above in the parent directory simply change

<link rel="stylesheet" type="text/css" href="assets/css/custom.css">

收件人

<link rel="stylesheet" type="text/css" href="../assets/css/custom.css">

这是一个相对链接,表示它将沿着一个结构向上移动.

This is a relative link meaning it will go up one structure and go from there.

但是您需要考虑从哪个文件中调用文件,因为我们不知道您的目录结构,这是我们可以使用所提供信息的最佳方法.

But you need to consider the location from which file it is called as we don't know your directory structure this is the best we can do with the information you've given.

这篇关于将HTML移至其他文件夹,现在无法正确链接CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆