标题页为重叠边框设置透明边框

时间:2015-10-12 18:26:31

标签: html css tabs border

我的.tab周围有一个边框,活动.tab-content { height:200px; width:400px; background-color: #aaa; border:1px solid #000; } .tabs-container { height:auto; width:400px; background-color:#aaabbb; } .tabs { width:360px; margin-left:20px; } .tab { display:inline-block; padding:5px 20px; } .tab.active { border-left:1px solid #000; border-right:1px solid #000; border-top:1px solid #000; border-bottom:transparent; background-color: #aaa; }周围有相同的边框。我尝试在底部添加透明边框无济于事。

my-setup

有没有办法,在两个边界重叠的情况下,有一个覆盖另一个?或者有更好的方法来实现这一目标吗?

这里有jsfiddle来显示我的基本设置。



<div class="tabs-container">
    <div class="tabs">
        <div class="tab active">This Tab</div>
        <div class="tab">That Tab</div>
    </div>
</div>

<div class="tab-content">
</div>
&#13;
div
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

您可以使用伪元素创建底部边框,使其与背景颜色相同,并将其定位为覆盖暗线。

.tab.active:after {
    content: '';
    border-bottom: 10px solid #aaa;
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
}

&#13;
&#13;
.tab-content {
    height:200px;
    width:400px;
    background-color: #aaa;
    border:1px solid #000;
}

.tabs-container {
    height:auto;
    width:400px;
    background-color:#aaabbb;

}

.tabs {
    width:360px;
    margin-left:20px;
}

.tab {
    display:inline-block;
    padding:5px 20px;
}

.tab.active {
    border-left:1px solid #000;
    border-right:1px solid #000;
    border-top:1px solid #000;
    background-color: #aaa;
    position: relative;
}
.tab.active:after {
    content: '';
    border-bottom:10px solid #aaa;
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
}
&#13;
<div class="tabs-container">
    <div class="tabs">
        <div class="tab active">This Tab</div>
        <div class="tab">That Tab</div>
    </div>
</div>

<div class="tab-content">
</div>
&#13;
&#13;
&#13;

或者只是将整个导航栏向下移动1px。

.tab.active {
    border-left:1px solid #000;
    border-right:1px solid #000;
    border-top:1px solid #000;
    background-color: #aaa;
    position: relative;
    bottom: -1px;
}

&#13;
&#13;
.tab-content {
    height:200px;
    width:400px;
    background-color: #aaa;
    border:1px solid #000;
}

.tabs-container {
    height:auto;
    width:400px;
    background-color:#aaabbb;

}

.tabs {
    width:360px;
    margin-left:20px;
}

.tab {
    display:inline-block;
    padding:5px 20px;
}

.tab.active {
    border-left:1px solid #000;
    border-right:1px solid #000;
    border-top:1px solid #000;
    background-color: #aaa;
    position: relative;
    bottom: -1px;
}
/* .tab.active:after {
    content: '';
    border-bottom:10px solid #aaa;
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
} */
&#13;
<div class="tabs-container">
    <div class="tabs">
        <div class="tab active">This Tab</div>
        <div class="tab">That Tab</div>
    </div>
</div>

<div class="tab-content">
</div>
&#13;
&#13;
&#13;