I am trying to style an anchor tag as following
The problem I have is that I am unable to figure out a way to cut out the right border, creating the effect shown in the image.
Note that it is important that the button background color is transparent and cuts out the border based on the line-height of the text.
This is what I’m currently able to achieve:
HTML
<a href="#">Neem contact met ons op</a>
CSS
a {
display: inline-block;
color: red;
text-decoration: none;
position: relative;
text-align: center;
padding: 10px 20px;
}
a::before {
content: "";
width: 100px;
border: 1px solid red;
position: absolute;
top: 0;
bottom: 0;
left: 0;
height: 100%;
}
2
Answers
Probably easiest, if you assemble the border out of three parts. The element itself gets a border-left only, and then you use two pseudo elements for the top and bottom part, respectively. (I’ve used different colors here for each part, so you can easily see which is which.)
Play with the
top
/bottom
percentages, if you want the partial borders on the right to be longer / shorter.Playing with gradients:
You can add another variable to control the offset: