Please see this fiddle:
Initially, the lines that form the outline of the button extend slightly past their intersection on the top-left & bottom-right.
On hover, this should transform so the extensions are from the top-right & bottom-left.
The bottom part works. The top is correct initially, but when transformed, it appears at an angle. What can I do to fix?
.custom-button {
font-size: clamp(0.875rem, 2vw, 1rem);
/* 14px base, responsive */
padding: 10px 30px;
color: var(--heading-color);
border: 1px solid;
font-weight: 600;
text-transform: capitalize;
display: inline-block;
position: relative;
transition: all 0.5s ease 0s;
background: transparent;
white-space: nowrap;
line-height: normal;
color: #4A83A5 !important;
border-color: #4A83A5 !important;
font-family: var(--font-raleway);
text-decoration: none !important;
}
.custom-button:hover,
.custom-button:focus {
color: #fff !important;
background-color: #4A83A5 !important;
text-decoration: none !important;
outline: none;
}
.custom-button:before {
content: "";
position: absolute;
top: 0;
left: 0;
transform: translate(-100%, -100%);
-webkit-transform: translate(-100%, -100%);
border: solid;
border-width: 0 1px 1px 0;
display: inline-block;
padding: 3px;
-webkit-transition: all .5s ease-out;
-moz-transition: all .5s ease-out;
transition: all .7s ease-out;
border-color: inherit;
}
.custom-button:hover:before {
left: 100%;
transform: translate(0, -100%) rotate(45deg);
-webkit-transform: translate(0, -100%) rotate(45deg);
}
.custom-button:after {
content: "";
position: absolute;
bottom: 0;
right: 0;
transform: translate(100%, 100%) rotate(0deg);
-webkit-transform: translate(100%, 100%) rotate(0deg);
border: solid;
border-width: 1px 0 0 1px;
display: inline-block;
padding: 3px;
-webkit-transition: all .5s ease-out;
-moz-transition: all .5s ease-out;
transition: all .7s ease-out;
border-color: inherit;
}
.custom-button:hover:after {
right: 100%;
transform: translate(0, 100%) rotate(90deg);
-webkit-transform: translate(0, 100%) rotate(90deg);
}
.custom-button.cta-button {
border-width: 1px;
padding: 10px 30px 10px 30px;
}
.custom-button.cta-button:before {
border-right-width: 1px;
border-bottom-width: 1px;
}
.custom-button.cta-button:after {
border-top-width: 1px;
border-left-width: 1px;
}
<a class="custom-button font-raleway cta-button" href="/donate">DONATE</a>