<button class="button--angle">An angle button</button>
<hr>
<button class="button--angle">An angle button with a longer name</button>
/**
* Button angle with NO pseudo-element
*/
.button--angle {
--bg-color: lightseagreen;
--bg-color-hover: steelblue;
--angle-width: 2rem;
--duration: 300ms;
--easing: cubic-bezier(0.165, 0.840, 0.440, 1);
--padding-x: 1rem;
--padding-y: 1rem;
background-color: var(--bg-color);
clip-path: polygon(0% 0%, calc(100% - var(--angle-width)) 0%, 100% 50%, calc(100% - var(--angle-width)) 100%, 0% 100%);
color: black;
display: inline-block;
padding: var(--padding-y) var(--padding-x);
padding-right: calc(var(--angle-width) + var(--padding-x));
transition: background-color var(--duration) var(--easing);
}
.button--angle:hover {
background-color: var(--bg-color-hover);
transition: background-color var(--duration) var(--easing);
}
/**
* demo styles
*/
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: ghostwhite;
font-family: system-ui, system, sans-serif;
line-height: 1.5;
max-width: 300px;
padding: 1rem;
}
button {
border: 0;
cursor: pointer;
font-family: system-ui, system, sans-serif;
font-weight: 600;
text-align: left;
}
hr {
border: 0;
margin: 2rem;
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.