Jquery切换添加z-index

问题描述 投票:3回答:1

我正在尝试做Toggle打开开发测试作为示例图像:

enter image description here

CSS:

.area1 {
    width: 50px;
    height: 200px;
    background: red;
    display: inline-block;
    z-index:99;
}
.area2 {
    width: 50px;
    height: 200px;
    background: green;
    display: inline-block;
    z-index:99;
}

jQuery的

$("#Go2").click(function () {
    $(".area1").animate({width:'toggle'},350);
    $(".area2").hide();

});
$("#Go").click(function () {
    $(".area2").animate({width:'toggle'},350);
    $(".area1").hide();
});

http://jsfiddle.net/gislef/kcve9qhg/

我尝试使用z-index,但不起作用


http://jsfiddle.net/gislef/kcve9qhg/6/

谢谢@ D.Gramm

jquery html css z-index
1个回答
4
投票

如果您希望z-index工作,您需要将位置设置为绝对或相对。然后z-index将生效。

© www.soinside.com 2019 - 2024. All rights reserved.