【发布时间】:2015-04-30 14:55:39
【问题描述】:
上下文:可聚焦元素内的绝对元素。
在 Firefox 36 中,如果可聚焦元素没有 CSS 位置(相对、固定或绝对),则单击内部元素不会将焦点设置到可聚焦元素...
知道这是否是一个已知的错误吗?
无法在 IE11 和 Chrome 上重现。
为了更好地理解这个问题,这里有一个例子:
/* this is just so that the squares are similarly displayed */
section {
position: relative;
display: inline-block;
margin-right: 75px;
}
div {
background-color: red;
width: 100px;
height: 100px;
color: white;
padding: 5px;
}
div:focus {
background-color: green;
}
div > span {
position: absolute;
display: inline-block;
top: 50px;
left: 50px;
background-color: blue;
width: 100px;
height: 100px;
padding: 5px;
}
Context: an absolute element inside a focusable element.<br>
In Firefox 36, if the focusable element does not have a "position: relative", a click on the inside element will not set the focus on the focusable element...<br>
(red block turns green when focused)
<br><br>
Edit: none works in IE
<br><br>
<section>
<div style="position: relative;" tabindex="-1">
With position: relative
<span>
click here
</span>
</div>
</section>
<section>
<div tabindex="-1">
With no position
<span>
click here
</span>
</div>
</section>
【问题讨论】:
-
我想我不妨在 bugzilla 上发布一个错误报告。这是:bugzilla.mozilla.org/show_bug.cgi?id=1138028
-
你能解释一下为什么你不想或不能使用“position: relative;”吗?
-
老实说,我不记得了。我想我最终做了不同的事情。但这不是重点。关键是这种行为没有意义。
-
我实际上认为它确实有道理。牢记这条评论:bugzilla.mozilla.org/show_bug.cgi?id=1138028#c1
-
这在 FF 66 中看起来已修复
标签: css firefox position focus css-position