且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将HTML移入不同的文件夹,现在它不能正确链接CSS

更新时间:2023-11-10 12:44:22

提供文件夹结构同时具有用户和资产父目录简单地改变

 < link rel =stylesheettype =text / csshref =assets / css / custom.css&GT; 

 < link rel =stylesheettype =text / csshref =../ assets / css / custom.css> 

这是一个相对链接,意思是它会沿着一个结构向前走。



但是你需要考虑它被调用的文件的位置,因为我们不知道你的目录结构,这是我们可以用你提供的信息做的***的。 p>

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.

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">

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

Thanks in advance!

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">

To

<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.