首页 新闻 会员 周边

IE浏览器无法引入css文件

0
悬赏园豆:30 [待解决问题]

最近发现一个问题,用<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文件。如果是的话,有什么方法解决呢?

小小三师弟的主页 小小三师弟 | 菜鸟二级 | 园豆:205
提问于:2014-06-13 09:59
< >
分享
所有回答(5)
0

j 加上这个<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">    在就是路径一定要写对../xx.css

zyxh | 园豆:201 (菜鸟二级) | 2014-06-13 10:20
0

顶部加上

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

然后下面引用要把.css路径写全

书香门第 | 园豆:191 (初学一级) | 2014-06-13 13:29
0

这个问题现在解决了吗?我也遇到同样的问题,求教

怀挺傅! | 园豆:202 (菜鸟二级) | 2015-07-02 17:48
http://blog.csdn.net/a8761087/article/details/49910435
支持(0) 反对(0) wakak | 园豆:202 (菜鸟二级) | 2015-11-25 10:44
0

博主问题解决吗

czhyuwj | 园豆:189 (初学一级) | 2015-09-23 22:27

http://blog.csdn.net/a8761087/article/details/49910435

支持(0) 反对(0) wakak | 园豆:202 (菜鸟二级) | 2015-11-25 10:44
0

让我来拯救你们吧。本大神的CSDN, http://blog.csdn.net/a8761087/article/details/49910435  保证解决,不要膜拜我

wakak | 园豆:202 (菜鸟二级) | 2015-11-25 10:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册