I have to create a button with the shape of a triangle in each side.
My approach was to create a div that contains 4 more divs (one per corner) so I can shape the triangles by overlapping divs, using linear-gradient and white color for the background.
The problem is that I also need to edit a border for the shape created, and it is not possible because every div has its own border.
Any way to obtain borders just for the shape of the final button?
.button {
height: 50px;
width: 140px;
position: relative;
background: darkred;
}
.button:hover {
background: black;
}
.text {
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
color: white;
font-size: 15px;
font-family: Tahoma;
}
.text:hover {
color: red;
}
.left,
.right {
width: 8%;
height: 50%;
position: absolute;
}
.left {
right: 0;
}
.right {
left: 0;
}
.down {
bottom: 0;
}
.up {
top: 0;
}
.left.up {
background: linear-gradient(225deg, white 87%, white 87%, transparent 0%);
}
.left.down {
background: linear-gradient(-45deg, white 87%, white 87%, transparent 0%);
}
.right.down {
background: linear-gradient(45deg, white 87%, white 87%, transparent 0%);
}
.right.up {
background: linear-gradient(135deg, white 87%, white 87%, transparent 0%);
}
<div class="button text">
<span>Discover More</span>
<div class="left up"></div>
<div class="left down"></div>
<div class="right up"></div>
<div class="right down"></div>
</div>