IE浏览器中jquery 使用load html 的background-image不能显示的问题

    在使用jquery中的load函数动态加载html页面时,html页面中带有background-image 元素。在IE浏览器中不能正确显示背景图片。好比: css

<html>
<head>
<style type='text/css'>
div.role_underline{
   height: 3px;
   width: 200px;
   background-image: url('images/role_underline.png');
   background-repeat: repeat-x;
   background-position:center;
}
</style>
</head>
<body>
<div class='role_underline'></div>
</body>
</html>

 当咱们在IE浏览器中,使用jquery 的load函数加载上面代码时并不能看到背景图片,可是firebox浏览器显示是正常的。 html

如何解决:方法一:不在css中定义背景图片,在元素的style中设置。<div class='role_underline' style="background-image: url('images/role_underline.png');"></div> jquery

方法二:在load 的回调函数中从新设置背景图片。$("div.role_under_line").css("background-image:","url('images/role_underline.png')"); 浏览器

注意:当咱们使用jquery 动态添加带有背景图片的元素时,也须要使用这方法。 函数

相关文章
相关标签/搜索