【发布时间】:2016-04-03 08:05:02
【问题描述】:
我有简单的代码
问题是红色的 div。它是动画的,但它的 z-index 比它的父级大,所以在动画时它会掩盖主 div。当我给动画 div z-index: -1 但是 :hover 不能正常工作(动画 div 消失)时,我可以解决这个问题。有人可以帮忙吗?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
.main {
width: 100px;
height: 100px;
background: green;
position: relative;
}
.main .bar {
height: inherit;
width: 300px;
position: absolute;
background: red;
left: -300px;
}
.main:hover .bar {
left: 100px;
transition: left .3s;
}
</style>
</head>
<body>
<div class="main"><div class="bar"></div></div>
</body>
</html>
【问题讨论】: