gpt4 book ai didi

CSS does not load in Internet explorer(无法在Internet Explorer中加载css)

转载 作者:bug小助手 更新时间:2023-10-25 21:52:03 25 4
gpt4 key购买 nike



So I am practicing HTML and CSS and doing some simple things like changing the color of the background in CSS. The problem is that when I load the page in Internet Explorer (IE 11) no changes show up. To test this further I loaded my page in Goggle Chrome and it displayed the page as expected.

因此,我正在练习HTML和CSS,并做一些简单的事情,比如在CSS中更改背景的颜色。问题是,当我在Internet Explorer(IE 11)中加载页面时,没有显示任何更改。为了进一步测试这一点,我在Gogger Chrome中加载了我的页面,它按照预期显示了页面。



This has happened a few times and I tried to make sure I deleted the cache in Internet Explorer, I made sure I was editing the right file and that the CSS style code was in the same directory. I made sure I did an Crtl + R / Crtl F5 refresh and it doesn't work. The weird thing though is that after loading it a few times in the past it works without me doing anything else.

这种情况已经发生过几次了,我试图确保我删除了Internet Explorer中的缓存,确保我编辑的文件是正确的,并且css样式代码位于同一目录中。我确保我做了一个Crtl+R/Crtl F5刷新,但它不工作。然而,奇怪的是,在过去几次加载之后,它可以在我不做其他任何事情的情况下工作。



Here is what I am trying to display:

以下是我想要展示的内容:



HTML FILE:

Html文件:



<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Lesson 12 - Fun With CSS Selectors</title>
<link type="text/css" rel="stylesheet" href="styles.css" media="all">
</head>
<body>

<h1>Title of the page</h1>

<p>Lorem ipsum dolor sit amet ultricies. Nunc at aliquet nunc.</p>

</body>
</html>


CSS FILE:

Css文件:



h1{
font-size: 30em;
font-weight: heavy;
font-color: red;
line-height: 10px;
}

body{
background-color: red;
}


The font color does not change in the h1 tag (probably because its not how you do it) but the background color changes in Google Chrome as well as the size of the font. In Explorer it remains a white page with the H1 tag content unchanged. Does anyone have any ideas on what could be happening?

H1标签中的字体颜色没有改变(可能因为这不是你怎么做的),但Google Chrome中的背景颜色以及字体的大小都会改变。在资源管理器中,它仍然是一个白色页面,H1标签内容保持不变。有谁知道会发生什么事吗?



UPDATE:



As of now when I load my page now in Internet Explorer 11 it now has the changes from the style CSS, but I changed nothing! I just opened it again... Can anyone explain what is going on, because this has happened multiple times

从现在起,当我在Internet Explorer11中加载我的页面时,它现在已经从样式CSS中进行了更改,但我什么都没有更改!我刚刚又打开了一次。有人能解释一下这是怎么回事吗,因为这种事已经发生过很多次了


更多回答

Are you building this locally or on a server?

您是在本地构建还是在服务器上构建?

Oftentimes what happens is your browser will cache the CSS file to make the page load faster and it takes it a minute to realize that the CSS file has changed. You can fix this by attaching a random GET variable to the end of the URL, e.g. file.css?24798210

通常情况下,您的浏览器会缓存css文件以加快页面加载速度,并且需要一分钟时间才能意识到css文件已更改。您可以通过将随机GET变量附加到URL的末尾来修复此问题,例如,file.css?24798210

I am running this locally. So Google Chrome updates the cache for CSS faster, which is why it takes effect right away compared to IE? Is there a why to change this in the browser, or is this a code change?

我在当地负责这件事。因此,Google Chrome更新css缓存的速度更快,这就是为什么与IE相比,它会立即生效?为什么要在浏览器中更改这一点,或者这是代码更改?

优秀答案推荐

Per your comments, seems as your problem is caching in IE.

根据您的评论,您的问题似乎是在IE中缓存。



You can try instructing the browser not to cache with some META keywords such as pragma and expires.

您可以尝试指示浏览器不要使用某些元关键字进行缓存,例如杂注和过期。



<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="-1"/>


Take a look at this article - So you don't want to Cache, Huh?

看一看这篇文章--所以你不想缓存,是吗?



And this question which suggests using this cross-browser solution:

这个问题建议使用这个跨浏览器解决方案:



<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />


Hope this helps!

希望这个能帮上忙!



We had this issue with Internet Explorer 11, it's weird but if you rename the stylesheet to anything without the word "style" it will start working!

我们在Internet Explorer11中遇到了这个问题,这很奇怪,但如果您将样式表重命名为任何不带“style”字的名称,它将开始工作!



This is only the case when the accessing the file locally, on a web server it seems to work fine

只有在本地访问文件时才会出现这种情况,在Web服务器上访问文件似乎运行良好



Replace font-color with color. And try an inline <style>body {background-color:#FF0000;} </style> to see if maybe the stylesheet isn't loaded properly.

用颜色替换Font-COLOR。并尝试内联,以查看样式表是否未正确加载。



I do not know if anyone still trace this problem, but I was also confronted with them. I am developing a django application. My CSS file named "style.css" was loading correctly (at least the inspector of google chrome told me that), but had no effect on my page. It cost me a great deal of time to figure out, as RayLau135 mentioned above, that you have to rename the CSS file to a name without "style". For sure, this is not a solution, but indeed a work around to deal with this problem and to save a lot of time and nerves.

我不知道有没有人还在追踪这个问题,但我也遇到了他们。我正在开发Django应用程序。我的名为“style.css”的css文件加载正确(至少谷歌Chrome的检查员告诉我),但对我的页面没有影响。就像RayLau135上面提到的,我花了很长时间才弄明白,你必须把这个css文件重命名为一个不带“style”的名字。当然,这不是一个解决方案,而是一种解决这个问题的变通办法,可以节省大量的时间和精力。



In my case, the same problem was caused by Alternate Data Stream of NTFS.

在我的例子中,同样的问题是由NTFS的备用数据流引起的。


If your HTML file was downloaded from somewhere, and has a Zone.Identifier as Alternate Data Stream, it refuses to load CSS/JavaScript files generated locally with no/different Zone.Identifier.

如果您的HTML文件是从某个地方下载的,并且具有作为备用数据流的Zone.IDENTIFIER,则它拒绝加载没有/不同Zone.IDENTIFIER的本地生成的CSS/JavaScript文件。


https://blog.malwarebytes.com/101/2015/07/introduction-to-alternate-data-streams/

Https://blog.malwarebytes.com/101/2015/07/introduction-to-alternate-data-streams/


You can remove these data manually or by streams command.

您可以手动或通过STREAMS命令删除这些数据。


https://learn.microsoft.com/ja-jp/sysinternals/downloads/streams

https://learn.microsoft.com/ja-jp/sysinternals/downloads/streams



In my case, the html/css files were inside a google drive directory (I'm using the Virtual Drive mode), moving the files outside worked immediately.

在我的例子中,html/css文件位于Google驱动器目录中(我使用的是虚拟驱动器模式),将文件移到外部立即起作用。


更多回答

Specifying no-cache or max-age=0 indicates that clients can cache a resource and must revalidate each time before using it. So you could use only one of them. developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control Invalid dates, like the value 0, represent a date in the past and mean that the resource is already expired. So also you can use only <meta http-equiv="expires" content="0" /> developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expires

指定no-cache或max-age=0表示客户端可以缓存资源,并且每次使用之前都必须重新验证。所以你只能用其中的一个。Developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control无效日期,如值0,表示过去的日期,表示资源已过期。因此您也只能使用developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expires

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com