Reputation: 1030
I have a border around my .tab-content
and the same border around active .tab
s. I've tried adding a transparent border on the bottom to no avail.
Is there a way to, where two borders overlap, have one override the other? Or is there a better way to accomplish this?
Here's a jsfiddle to show my basic set up.
.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;
}
<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>
Upvotes: 1
Views: 1208
Reputation: 78756
You can use a pseudo element to create the bottom border, make it the same color as the background, and position it to cover the dark line.
.tab.active:after {
content: '';
border-bottom: 10px solid #aaa;
position: absolute;
bottom: -1px;
left: 0;
width: 100%;
}
.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%;
}
<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>
Or just move the whole navbar 1px down.
.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-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%;
} */
<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>
Upvotes: 2