css url() not recognized in internet explorer 10

谁说胖子不能爱 提交于 2019-12-19 02:14:50

问题


I have this line in my CSS:

.ui-icon-zoom-in { content: url(images/16x16/ZoomIn.png); } 

Which I am using with jQuery UI Button widget like this:

$("#zoomin").button({ text: false, icons: { primary: "ui-icom-zoom-in" } });

In Chrome, I can see the image centered within the button. However, in IE10, I do not see the image.

Am I missing something here?


回答1:


The content property is only valid on :before and :after pseudo-elements. You should change it to:

.ui-icon-zoom-in { 
  background: url(images/16x16/ZoomIn.png) no-repeat; 
  width:16px;
  height:16px;
}

Apart from that, IE8+ only supports content property if a valid DOCTYPE is specified.




回答2:


The content property is only accepted on :before and :after pseudo-elements in CSS3. You should probably use a jQuery selector to append the image to the object:

$("#zoomin").html("<img src='images/16x16/ZoomIn.png' alt='Zoom In'>");



回答3:


I had the same situation in IE 11. The content is <div class="image"> </div> So in Chrome it works like this

.image {
  content: url("image.jpg");
}

To make it Works in IE i have set the content option to :after element. Like

.image:after {
  content: url("image.jpg");
}


来源:https://stackoverflow.com/questions/16132460/css-url-not-recognized-in-internet-explorer-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!