css新创建的div应该落后于前一个div

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

在这里,我正在尝试创建浏览器选项卡。

JsFiddle

.intrnlTabs {
    background: #f0f1f3;
    height: 35px
}
.intrnlTab {
    background: #e7e9ec;
    display: inline-block;
    height: 30px;
    text-align: left;
    margin-top: 5px;
    line-height: 35px;
    border-top-left-radius: 10px;
    position: relative;
    margin-left: 12px
}
.intrnlTxt {
    display: inline-block;
    max-width: 150px;
    height: inherit;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    min-width: 30px;
    padding: 0 20px 0 10px
}
.intrnlCls {
    position: absolute;
    right: -23px;
    height: inherit;
    background: #dee1e5;
    box-sizing: border-box;
    top: 0;
    width: 33px;
    transform: skewX(30deg);
    border-top-right-radius: 5px;
    cursor: pointer;
    display: inline-block;
    text-align: center
}
.intrnlCls:hover {
    background: #d7d8d8
}
.intrnlClsicon {
    transform: skewX(-30deg);
    display: inline-block
}

输出我得到了什么

enter image description here

输出我期待的

enter image description here

我想新添加的标签标题应该在前一个标签后面,而不添加z-index值。我已经实现了添加z-index值。但是,我不想添加z-index值。

css css3 transform
1个回答
2
投票

您不需要为每个项目计算特定的z-index,也不需要通过JS分配它。

将z-index为1添加到这些“X”项已经足以实现您的目标:

.intrnlCls { z-index:1; }
© www.soinside.com 2019 - 2024. All rights reserved.