Skip to content

Instantly share code, notes, and snippets.

@pa-ulander
Last active June 2, 2020 19:33
Show Gist options
  • Save pa-ulander/b85a715b80babd3023047babd4eaf6c6 to your computer and use it in GitHub Desktop.
Save pa-ulander/b85a715b80babd3023047babd4eaf6c6 to your computer and use it in GitHub Desktop.
poc buttons with trapezoid shaped bottom border as tabs - https://codepen.io/pa-ulander/full/YzwzwyX
<!DOCTYPE html>
<html>
<body>
<style>
button {
border-bottom: 10px solid #9b9b9b;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 0;
box-sizing: border-box;
display: inline-block;
position: relative;
width: 250px;
height: 50px;
background: none;
font-size: 14px;
font-weight: 600;
color: #ffffff;
padding: 0;
bottom: 0;
outline:none;
}
button.active {
border-bottom: 10px solid #f0f0f0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 0;
}
button span {
display: block;
position: absolute;
bottom: 0;
width: 100%;
padding-bottom: 10px;
}
button.active span {
display: block;
position: absolute;
bottom: -4px;
left: -2px;
border-bottom: 4px solid #15bf81;
border-left: 2px solid transparent;
border-right: 2px solid transparent;
border-top: 0;
}
.nav {
background-color: #4d5f7a
}
.head {
background-color: #f0f0f0;
height: 15px;
padding: 20px;
}
.content {
background-color: #f0f0f0;
height: 400px;
padding: 20px;
}
body {
font-family: Roboto, sans-serif;
padding: 20px;
background-color: #ddd;
}
</style>
<div class="head">
Header
</div>
<div class="nav">
<button class="active">
<span>BUTTON TAB 1</span></button>
<button>
<span>BUTTON TAB 2</span>
</button>
<button>
<span>BUTTON TAB 3</span>
</button>
</div>
<div class="content">
<p>
We can apply this with <a href="http://www.material-ui.com/#/components/tabs" target="_blank">Material UI Tabs Component</a> in our project, using Tab properties &raquo; <code>buttonStyle</code>
</p>
<script type="text/javascript">
const buttons = document.querySelectorAll('button');
Array.from(buttons).map(item => {
item.addEventListener('click', function(event) {
buttons.forEach(btn => {
btn.classList.remove('active');
})
this.classList.add('active');
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment