IE浏览器无法引入css文件

IE浏览器无法引入css文件

最近发现一个问题,用<link rel=”stylesheet” type=”text/css” href=”test.css” />在ie11浏览器下无法正常引入。直接在页面使用<style></style>没有问题。

我的浏览器版本

其他版本没有测试过,但非ie浏览器都没有问题。

 1 <!doctype html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>图片水平垂直居中 - 前端博客demo</title>
 6     <!--<link rel="stylesheet" type="text/css" href="http://baike.baidu.com/static/index/index/index_c4c99e8f.css" />-->
 7     <link rel="stylesheet" type="text/css" href="test.css"  />
 8 </head>
 9 <body>
10 <div class="index">
11   <a href="#">我是宋体</a>
12 </div>   
13 </body>
14 </html>
1 .index{font-family:"宋体"}.index a{color:#9c6d32;text-decoration:none}.index a:hover{text-decoration:underline}.index h3{font-family:"微软雅黑";font-size:15px;color:#333}.index img{display:block}.index .container{position:relative;border-bottom:1px solid #e6e6e6;overflow:hidden}.index .container .main{_overflow:hidden}.index .version{text-align:center;font-size:14px}.index .version a{text-decoration:none}.index .version .cur{color:#000}.index div.beShort{width:980px;margin:0 auto}.ad-side{padding:5px 9px;background:#fcfcfc;border:1px solid #e6e6e6;border-top:0;border-bottom:0}.btn-entry{margin:20px 0 0 0}.btn-entry .create-entry,.btn-entry .perfect-entry{float:left;padding:0 0 0 17px;background:url(/static/index/index/img/indexPageIcon_ec849ae4.png) -61px -348px no-repeat;display:inline-block;width:108px;height:42px;text-align:center;line-height:42px;color:#7692af;font-size:14px;font-weight:bold;overflow:hidden;zoom:1}.btn-entry .perfect-entry{background-position:-186px -348px}.btn-entry .create-entry:hover{background-position:-61px -390px;color:#4274a6;text-decoration:none;padding:0 0 0 17px;zoom:1}.btn-entry .perfect-entry:hover{background-position:-185px -432px;color:#4274a6;position:relative;margin-right:-1px;right:1px;padding-left:18px;text-decoration:none;height:42px;overflow:hidden}.pi-left{position:absolute;left:50%;top:129px;margin:0 0 0 -568px;background:url(/static/index/index/img/indexPageIcon_ec849ae4.png) -326px -245px no-repeat;width:78px;height:184px}.ad-side{padding:20px 19px 0}.ad-side-last{padding:10px 19px 20px}

测试代码如上:

调试了很久,发现只有去掉顶部的<!DOCTYPE html>或者设置为<!DOCTYPE>才能导入。

设置为比较常用的

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

都不行,但是<link rel=”stylesheet” type=”text/css” href=”http://baike.baidu.com/static/index/index/index_c4c99e8f.css” />

是能够导入的。我的css内容就是复制的这个css文件,也就是说css文件上应该没有问题的。可是什么原因造成无法导入的呢?是不是浏览器的安全策略导致无法加载本地css文件。如果是的话,有什么方法解决呢?

IE浏览器无法引入css文件

相关文章:

你感兴趣的文章:

标签云: