我正在处理我的项目,但我在 css 中遇到了 z-index 问题。我已经用谷歌搜索了一整天,但还没有找到适合我的解决方案。问题是,我得到另一个 div 下的 div。它必须是带有 z-index 的东西。希望有人能找出我做错了什么......
$(".box").click(function() {
$(this).css({
"-webkit-transform-style": "preserve-3d",
"background-color": "red",
"box-shadow": "0px 0px 10px red",
"-webkit-transition:": "all .2s ease-in",
"zoom": "1",
"z-index": "10",
"-webkit-transform": "rotateY(0deg)"
});
$(this).mouseleave(function() {
$(this).css({
"-webkit-transform-style": "preserve-3d",
"background-color": "blue",
"box-shadow": "",
"-webkit-transition:": "all .2s ease-out",
"zoom": "",
"z-index": "1",
"-webkit-transform": "rotateY(45deg)"
});
});
});
#blue {
-webkit-perspective: 600px;
}
#blue .box {
position: absolute;
zoom: 0.7;
background-color: blue;
-webkit-transform: rotateY(45deg);
-webkit-transition: all .2s ease-out;
z-index: 0;
height: 100px;
width: 200px;
margin-left: 50px;
margin-top: 50px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="blue" class="container" style="margin-left: 50px">
<div class="box" id="first"></div>
</div>
<div id="blue" class="container" style="margin-left: 200px">
<div class="box" id="second"></div>
</div>
我也把所有的东西放在了jsFiddle