【发布时间】:2015-11-17 20:27:47
【问题描述】:
更新
我添加了一个 jsfiddle,其中包含来自该站点的更多代码。这个工作就像我描述的那样。我会尽快添加额外的代码,但样式表有 1000 多行,我不知道什么是相关的。
https://jsfiddle.net/noL14v9w/1/
原帖
我在 IE10 中。我有一个方形 div,300 像素 x 300 像素。在 div 里面,我有一些文字。如果我单击文本,它会触发我的单击事件。如果我点击 div 而不是文本,它不会触发点击事件。
当我设置 CSS 悬停类时,也会出现同样的问题。仅当我将鼠标悬停在文本上时才会应用悬停规则,而不是 div 中的其他任何位置。
HTML:
<div class="openStartAuditButton" onclick="alert('WTF');">asdf</div>
CSS:
.openStartAuditButton{
height:300px;
width:300px;
margin-top:20px;
font-size:24px;
background-color:grey;
color:white;
margin-left:auto;
margin-right:auto;
text-align:center;
}
.openStartAuditButton:hover{
background-color:lightgrey;
}
/* I also have box sizing set on all elements, but removing this does nothing: */
* {
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
-moz-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
}
文档类型:
<!DOCTYPE html>
<html lang="en">
...
应用规则:
【问题讨论】:
-
this jsfiddle 似乎对我有用,我错过了什么吗?
-
“不在 div 中的其他任何地方”是什么意思..
-
@scaisEdge 我的意思是任何非文本的地方。仅当我单击文本时才会触发单击。如果我单击 div 但不是在文本上,它不会触发。它有一个固定的宽度和高度,所以文本不会填满 div。
-
@ScottKaye 那个小提琴也适合我,我认为它可能是我网站上的其他东西在做,但我不知道是什么。我希望有人知道导致此问题的 IE 异常快速并知道修复方法。
-
即使在 IE 9 上似乎也对我有用(IE8 jsFiddle 停止工作..)。
标签: javascript html css internet-explorer-10