外部CSS在IE11中不起作用 [英] External CSS not working in IE11

查看:165
本文介绍了外部CSS在IE11中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了自己的嵌入式服务器,可以产生对网页浏览器的响应。
生成的主页面就像下面的html一样。



 <!DOCTYPE html>< html>< head>< link rel =stylesheethref =styles.css>< title> ABC Inc. Web Configurator< / title>< / head> < body>< b>< body>< b>< body><配置>配置< / tr>< tr>< td>< a href = Logger> Logger< / a>< / td>< / tr><表>< footer> Web配置器© ABC Inc. 2014  -  2015< / footer>< / body>< / html>  

生成的CSS文件是

.even {background-color:#EFF;}。odd {background-color:#FFE;}。title {background-color:#226;颜色:#EEF;} a {color:#36C; text-decoration:none;} a:hover {text-decoration:underline;} body {font-family:Tahoma; font-size:100%;} footer {color:#999; font-size:0.7rem;} nav {background-color:#DDF; font-size:1.1rem;} td {min-width:60px;}

当我通过Chrome 43或Firefox 39浏览主页时,它们都可以。
但是,当我使用IE11时,CSS不适用于html,尽管我可以确保IE11可以从我的服务器访问CSS文件。如果我在IE中按F12,DOM管理器在这个页面中没有显示样式表。


顺便说一下,我的网址是 http:// localhost:8888 / ,并且需要基本身份验证。
任何想法如何解决它?



更新


  1. 我已阅读计算器线程之前,我相信我的问题不是关于浏览器缓存。感谢Mauro收到通知。

  2. 我试过Chrome + IE tab2,CSS可以工作,但不适用于导航和页脚标记。我猜IE标签不支持HTML5。

更新 b


  1. 我试过封闭和非封闭的链接标签,它们都不能解决我IE11的问题。


  2. 我尝试禁用基本身份验证,但仍无法正常工作。

  3. > UPDATE


    1. CSS也可以在Firefox 39中使用。


    2. 该CSS可与IE11兼容模式一起工作(但HTML5标记将被忽略)。

    3. =h2_lin>解决方案

在比较了很多网站之后,我发现这个问题可以通过简单地移除html5声明<!DOCTYPE html> 。但是,我不明白为什么IE11的行为是这样的,它应该有支持html5。



PS。我读过这篇SO文章并添加 type =text / css,但似乎IE11从不关心这一点。


I have wrote my own embed-server, which can generate response to web browsers. The generated "main page" is like the following html.

<!DOCTYPE html>
<html><head><link rel="stylesheet" href="styles.css"><title>ABC Inc. Web Configurator</title></head><body>
<nav><p>[<b>Home</b>]</p></nav>
<table>
<tr><td><a href=Config>Config</a></td></tr>
<tr><td><a href=Logger>Logger</a></td></tr>
</table>
<footer>Web Configurator &copy; ABC Inc. 2014 - 2015</footer></body></html>

And the generated CSS file is

.even{
	background-color: #EFF;
}
.odd{
	background-color: #FFE;
}
.title{
	background-color: #226;
	color: #EEF;
}
a{
	color: #36C;
	text-decoration: none;
}
a:hover{
	text-decoration: underline;
}
body{
	font-family: Tahoma;
	font-size: 100%;
}
footer{
	color: #999;
	font-size: 0.7rem;
}
nav{
	background-color: #DDF;
	font-size: 1.1rem;
}
td{
	min-width: 60px;
}

When I browse the main page by Chrome 43 or Firefox 39, they're both okay. However, when I use IE11, the CSS not apply to the html, even though that I can make sure IE11 have access the CSS file from my server. If I press F12 in IE, the DOM manager shows no stylesheet in this page.

BTW, my URL is http://localhost:8888/, and need a basic authentication. Any idea how can I fix it?

UPDATE

  1. I've read the stackoverflow thread before, and I'm sure my problem is not about browser caching. Thanks Mauro for notification.

  2. I've tried Chrome + IE tab2, the CSS works, but not apply to nav and footer tag. I guess IE tab not support HTML5.

UPDATE

  1. I've try both of closed and non-closed link tag, both of them are not solve my problem with IE11.

  2. I've try to disable Basic Authentication, still not working.

UPDATE

  1. The CSS also works in Firefox 39.

  2. The CSS works with IE11 + Compatible mode (but HTML5 tags will be ignored).

解决方案

After I compare a lot of website, I find out this problem could be solved easily by just remove the html5 declaration <!DOCTYPE html>. However, I don't understand why IE11 act like that, it should have support html5.

PS. I've read this SO article and add type="text/css", but it seems IE11 never care about that.

这篇关于外部CSS在IE11中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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