I'm trying to make a menu with tabs. The style of the tabs is like so:
I need the background to be transparent and have a border, on hover, it will fill the background with another color.
I have tried to do this with pure CSS, I can get the shape correct using :before and :after, however as I'm using borders to do this, I cannot add a border on both sides and end up with this:
#pointer {
width: 200px;
height: 40px;
position: relative;
background: red;
text-align: centre;
border: 1px solid white;
}
#pointer:after {
content: "";
position: absolute;
left: -20px;
bottom: 0;
width: 0;
margin-bottom: 20px;
height: 0;
border-right: 20px solid red;
border-top: 0px solid red;
border-bottom: 20px solid transparent;
}
#pointer:before {
content: "";
position: absolute;
right: -20px;
bottom: 0;
width: 0;
height: 0;
border-left: 20px solid red;
border-top: 20px solid transparent;
border-bottom: 20px solid red;
}
<div id="pointer">Tab 1</div>
I have also tried to do this with SVG, I can get the shape and border correct, but the hover area is a lot larger then the border.
<svg
class="test"
xmlns='http://www.w3.org/2000/svg'
viewBox='0 0 64 64'
width='150' height='150'
stroke='white'
fill='red'>
<path d='M8 30 L62 30 L62 22 L56 16 L2 16 L8 22 Z' />
</svg>
How can I either, complete the borders with CSS attempt, or make the hover area of the SVG match the border exactly?

