Html 如何从网站获取css文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25644276/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:38:21  来源:igfitidea点击:

How get css files from website?

htmlcssresources

提问by Hrant Vardanyan

I'm trying to get the content of css files of a website....

我正在尝试获取网站的 css 文件的内容....

 <link href="/files/includes/templates-css-main.css" rel="stylesheet" type="text/css" />

For example, it's the link of css ref of http://paceoil.ca/. When I tried to send a request for getting a css file to this url http://paceoil.ca/files/includes/templates-css-main.css, I got an unexpected result.

例如,它是http://paceoil.ca/的 css ref 链接。当我尝试向这个 url http://paceoil.ca/files/includes/templates-css-main.css发送获取 css 文件的请求时,我得到了一个意想不到的结果。

Any help? Thanks in advance.

有什么帮助吗?提前致谢。

回答by Woodrow Barlow

On the particular website in question, the reason you're not seeing what you expected is because they've used an uncommon technique called @importto load several stylesheets into one. In general, your method is correct -- http://paceoil.ca/files/includes/templates-css-main.cssis indeed a link to their stylesheet.

在有问题的特定网站上,您没有看到预期的原因是因为他们使用了一种不常见的技术,称为@import将多个样式表加载到一个中。一般来说,你的方法是正确的——http://paceoil.ca/files/includes/templates-css-main.css确实是他们样式表的链接。

Inside that stylesheet, you'll see the following statements:

在该样式表中,您将看到以下语句:

@import 'templates-css-reset.css';
@import 'templates-css-layout.css';
@import 'templates-css-type.css';
@import 'templates-css-nav.css';
@import 'modules-mod_superfishmenu-tmpl-css-superfish.css';

These lines simply load the contents of other .cssfiles all together. The other CSS files can be found at:

这些行只是一起加载其他.css文件的内容。其他 CSS 文件可以在以下位置找到:

It should also be noted that on some websites (most commonly on huge websites like facebook), CSS files are not necessarily statically generated. Some servers run "CSS-preprocessing" which allows them to embed code in CSS that is executed and translated before your browser ever sees it. In cases like this, it is impossible to view that code unless the owner shares it with you.

还应该注意的是,在某些网站上(最常见的是在像 facebook 这样的大型网站上),CSS 文件不一定是静态生成的。一些服务器运行“CSS 预处理”,这允许它们将代码嵌入到 CSS 中,并在您的浏览器看到它之前执行和翻译。在这种情况下,除非所有者与您共享,否则无法查看该代码。

回答by Bramos

press F12, resources. then you should see the cssfile of a site

按F12,资源。那么你应该看到css一个站点的文件