【发布时间】:2019-02-26 11:52:35
【问题描述】:
在这里,我正在尝试创建浏览器选项卡。
.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
}
输出我得到的东西
输出我的期望
我希望新添加的选项卡标题应该放在前一个选项卡的后面而不添加 z-index 值。我已经实现了添加 z-index 值。但是,我不想添加 z-index 值。
【问题讨论】:
-
.intrnlCls { z-index:1; }完成…… -
你能解释一下为什么不想使用
z-index吗?这将完全影响可能答案的范围。 -
@MrLister 我猜他们的意思是他们不想计算基于元素索引或其他什么的特定 z-index 值,并且不知道这一点需要一个“静态”的。
-
@MrLister 选项卡不是静态的。它是动态创建的。所以,我不想使用脚本添加 z-index。
-
@04FS 是的。我不知道这个静态代码
z-index:1会解决这个问题。