Reputation: 12945
I am trying to create html multiple tab like below screenshot .
In my below code I have created tabs but not able to give same look like how to cut button like / and \ on top . Also line below tab button
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<style>
body {font-family: Arial;}
/* Style the tab */
div.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
/* Style the buttons inside the tab */
div.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
}
/* Change background color of buttons on hover */
div.tab button:hover {
background-color: #ddd;
}
/* Create an active/current tablink class */
div.tab button.active {
background-color: #ccc;
}
/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}
</style>
</head>
<body>
<div class="tab">
<button class="tablinks" onclick="openCity(event, 'Filter')">Filter</button>
<button class="tablinks" onclick="openCity(event, 'Algorithm')">Algorithm</button>
<button class="tablinks" onclick="openCity(event, 'Settings')">Settings</button>
</div>
<div id="Filter" class="tabcontent" style="display:block">
<h3>Filter</h3>
<p>Filter is the capital</p>
</div>
<div id="Algorithm" class="tabcontent">
<h3>Algorithm</h3>
<p>Algorithm</p>
</div>
<div id="Settings" class="tabcontent">
<h3>Settings</h3>
<p>Settings Tab Content</p>
</div>
<script>
function openCity(evt, cityName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}
</script>
</body>
</html>
Upvotes: 0
Views: 103
Reputation: 1465
Well you can do this with clip-path
main issue is getting the borders, because clip-path
doesn't support them, but we can make them with a small hack. Here is the example for you it should give you a nice start how to do this:
.slanted {
width: 200px;
height: 40px;
background-color: black;
-webkit-clip-path: polygon(0 0, 94% 0, 100% 100%, 0% 100%);
clip-path: polygon(0 0, 94% 0, 100% 100%, 0% 100%);
position: relative;
}
.slanted:before {
content: '';
width: 198px;
height: 38px;
-webkit-clip-path: polygon(0 0, 94% 0, 100% 100%, 0% 100%);
clip-path: polygon(0 0, 94% 0, 100% 100%, 0% 100%);
background: red;
display: block;
position: absolute;
top: 1px;
left: 1px;
}
<div class="slanted"></div>
Upvotes: 1