javascript - IE 悬停在链接上不起作用

标签 javascript html css internet-explorer hover

我对 <a> 有疑问悬停功能上的标签。

<a href='#' onClick='javascript:showPrev();'class='prev'> </a>

问题出在 CSS 代码中。如果我设置 background-color在两个a{}a:hover{}图像将可见。否则,如果没有 background-color或设置为 none ,图像不会在悬停时显示。

这是我的 CSS

a.next {
  outline:none;
  position: absolute; 
  text-decoration:none; 
  color:black; 
  z-index: 800; 
  left: 534px;  
  top: 0px; 
  width: 266px; 
  height: 600px; 
  display: inline;
}

a.prev {
  outline:none;
  position: absolute; 
  text-decoration:none; 
  color:black; 
  z-index: 800; 
  left: 0px;  
  float:left; 
  top: 0px;  
  width: 266px; 
  height: 600px; 
  display: inline;
}

#slideshow a.next:hover {   
  outline:none;
  position: absolute; 
  text-decoration:none; 
  color:black; 
  z-index: 800; 
  left: 534px;  
  top: 0px; 
  width: 266px; 
  height: 600px; 
  display: inline; 
  background:url(../images/next.png) 90% 65% no-repeat;
}

#slideshow a.prev:hover {   
  outline:none;
  position: absolute; 
  text-decoration:none;    
  color:black; 
  z-index: 800; 
  left: 0px;  
  float:left; 
  top: 0px;  
  width: 266px; 
  height: 600px; 
  display: inline; 
  background:url(../images/prev.png) 10% 65%  no-repeat;
}

有人知道可能是什么问题吗?提前致谢。

最佳答案

似乎确实存在一些奇怪的 IE 问题,这意味着 a 标签保留在图像后面,除非您设置背景属性,我目前无法弄清楚为什么...

但是...

您可以通过将背景属性从 :hover 状态复制到“正常”a 状态,然后添加一个大的负背景位置来解决这个问题,这样它们就可以有效地隐藏起来,直到它们悬停在上面,例如:

a.next {
  outline:none;
  position: absolute; 
  text-decoration:none; 
  color:black; 
  z-index: 800; 
  left: 534px;  
  top: 0px; 
  width: 266px; 
  height: 600px; 
  display: inline;

  background:url(../images/next.png) 90% -1000% no-repeat;
}

这应该可行

关于javascript - IE 悬停在链接上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7698232/

相关文章:

javascript - 数组在 Javascript 中不起作用

html - Bootstrap 表 css/数据库

javascript - 表单提交时检查文件类型?

html - 响应使用 Bootstrap 从两列更改为一列

html - <center> 标签在 IE 中不起作用

css - zurb : Icons within buttons

javascript - 如何让文本区域在更新时保持滚动到底部

javascript - 在 Angular 2 中呈现一定数量的子组件

javascript - 如何通过 Ajax 将 PHP 输出返回到页面?

javascript - Websocket 如何连接到集群内正确的子进程?