【发布时间】:2013-05-17 02:24:43
【问题描述】:
当您转换对象时,直到您移动鼠标,悬停状态才会更新(:hover 的 CSS 规则)。
当您将 DOM 元素移动到用户鼠标下方时(使用 transition 或其他等效项),悬停状态在鼠标移动之前不会更新。有什么解决方法吗?我不想进入花哨的 JS 来触发“鼠标悬停”事件。
JSFiddle:http://jsfiddle.net/forestka/8xJkR/1/
HTML:
<div id="below">
This is the one below. (Now move the mouse.)
</div>
<div id="hover">
Click me! (But don't move the mouse after you click)
</div>
CSS:
#hover:hover,
#below:hover {
background-color: #f00;
}
#below {
padding:10px;
position: absolute;
top:0;
left:0;
}
#hover {
background-color: #ddd;
padding: 10px;
position: absolute;
left: 0;
top:0;
transition: top 1s ease;
z-index: 100;
}
#hover.hidden {
top: 50px;
}
旁注:所以不会让我插入没有代码的 JSFiddle 链接??
【问题讨论】:
-
您到底想完成什么?你的问题很混乱
-
当您更改用户鼠标下方的元素时,CSS
hover selector (#element:hover`) 在您移动鼠标之前不会应用。 -
在什么浏览器中?因为它在 Firefox 21 上运行良好
-
Chrome 开发者 28.0.1500.
标签: html css-transitions