阅读这两个问题后:如何在细节标签的关闭事件上添加CSS转换?
- How To Add CSS3 Transition With HTML5 details/summary tag reveal?
- How to make <'details'> drop down on mouse hover
我对你有一个新的!
问题
我想在关闭<details>
标签的事件的动画。我认为只是恢复开放的动画会做这项工作,但不幸的是,没有。
$(function() {
$('details').on('mouseover', function() {
$(this).attr('open', true);
}).on('mouseout', function() {
$(this).attr('open', false);
}).on('click', function(e) {
e.preventDefault();
})
});
details[open] SUMMARY~* {
animation: sweepin .5s ease-in-out;
}
details[close] SUMMARY~* {
animation: sweepout .5s ease-in-out;
}
@keyframes sweepin {
0% {
opacity: 0;
margin-left: -10px
}
100% {
opacity: 1;
margin-left: 0px
}
}
@keyframes sweepout {
0% {
opacity: 1;
margin-left: 0px
}
100% {
opacity: 0;
margin-left: -10px
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<details>
<summary>Here my little summary</summary>
<p>... Do you want more details?</p>
<p>Here have some details!</p>
</details>
问题
你是否认为这是可能的吗?
它有一个bug,如果动画没有完成它不会删除.close类。 – vlk
@vlk如何重现错误? – guest271314
尝试在动画完成之前将鼠标移出。 – vlk