样式表未加载到子页面上 [英] Stylesheets aren't loading on sub-pages

查看:48
本文介绍了样式表未加载到子页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我的HTML不能正确链接我的CSS?使用来自html5up.com的Prologue模板...在主目录中(我的意思是index.html所在的位置),我为要显示的不同产品创建了一个子文件夹.此文件夹包含一些文件: 125st.html 125stmain.css 和Dreamweaver创建的名为 _notes 的文件夹.这是应该链接到125stmain.css的125st.html中的代码:

Why isn't my HTML linking my CSS properly? using the Prologue template from html5up.com... In my main directory (I mean where index.html is) I created a subfolder for the different products I want to display. This folder contains a few files: 125st.html, 125stmain.css, and a folder called _notes created by Dreamweaver. Here is the code in the 125st.html that should be linking to the 125stmain.css:

<link rel="stylesheet" href="products/125st/125stmain.css" />

当我访问 shercousa.com/products/125st/125st.html 时(对您不起作用,我只是欺骗了hosts文件,使其转到本地保存而不是实时站点保存)虽然我在研究它),但没有显示CSS,只有HTML.我只是从 index.html 文件(有效)复制了这一行,然后更改了文件夹以尝试将其定向到我创建的CSS克隆中.如果这行不通,我尝试复制并粘贴在主站点上可用的逐行逐字记录,但是当链接到 125st.html 时,它仍然完全不会加载CSS.我有点新,如果很难遵循,对不起.如果有人需要查看,我可以详细说明或发布更多代码.

When I visit shercousa.com/products/125st/125st.html (It wont work for you, I've just tricked the hosts file to go to my local save instead of the live site while I work on it) it shows no CSS only the HTML. I just copied this line from the index.html file (which works) and changed the folder to try to direct it to the CSS clone I created. When this didn't work I tried copying and pasting the original line verbatim that works on the main site, but when linked in 125st.html still loads no CSS at all. I'm a bit new so sorry if I'm a bit hard to follow. I can elaborate or post any more code if anyone needs to see it.

同样,我的图像也没有加载,即使是html文件中链接的图像也没有加载.

Also my images are not loading, even the ones linked in the html file.

推荐答案

如果我没记错,这是一个简单的解决方案.

If i'm not wrong, this have an easy solution.

如果您位于 host/products/125st/125st.html 上,并且以这种方式链接了CSS:

If you're on host/products/125st/125st.html and you linked CSS this way:

<link rel="stylesheet" href="products/125st/125stmain.css" />

正在发生的情况是您的文件215st.html试图查找: host/products/125st/125st.html/products7125st/125stmain.css

What it's happening there is that your file 215st.html is trying to find: host/products/125st/125st.html/products7125st/125stmain.css

因此,您可以通过以下两种方式链接CSS:

So you can either link your css with both this ways:

<link rel="stylesheet" href="/products/125st/125stmain.css" />

<link rel="stylesheet" href="125stmain.css" />

我希望这对您有用:)对不起,我的英语!

I hope this works for you :) And sorry for my english!

这篇关于样式表未加载到子页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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