CSS 背景图片在 IE6 和 IE7 中不一致

标签 css internet-explorer-6 internet-explorer-7

我有一个通过 javascript 生成的跨度,其 css 类如下:

.class1{  
  width:25px;
  height:25px;
  background-image: url(pic.png);
  background-repeat:no-repeat;
  background-position: center; 
  cursor:pointer;
  margin-left:10px;
 }  

问题出在 html 页面上,我可以在 IE7 中看到指针光标,但看不到背景图像。

在 IE6 中,两者都显示,没问题。

最佳答案

Span,顾名思义,就是一个内联元素,试试在.class1中加入display:block;或者display:inline-block; .同时添加图像的 heightwidth

像这样:

.class1{  
  width:25px;
  height:25px;
  background-image: url(pic.png);
  background-repeat:no-repeat;
  background-position: center; 
  cursor:pointer;
  margin-left:10px;

display:block; /*or inline-block*/
height:100px;
width:100px; /*img height and width*/
 }  

关于CSS 背景图片在 IE6 和 IE7 中不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2652653/

相关文章:

jquery - float 和 jQuery UI 按钮

html - Bootstrap 4 导航栏下拉问题

html - 我在相对 div 中有绝对位置,当我放大到设备布局时与父级重叠

html - 无法使色带边缘保持在顶部

javascript - 在 Mac 上的 IE6 中测试

css - IE7 中是否支持 "inherit"的 CSS?

php - 登录到ajax加载首页

java - Internet Explorer 6 发送随机 GET

javascript - JS polyfill CSS 子选择器到 IE6

CSS 在 IE 7 上无法正常工作