Вот идея использования mask
на основе этого предыдущего ответа :
.button {
display:inline-block;
margin:10px;
padding:5px;
font-size:25px;
width:250px;
text-align:center;
line-height:1.8;
background:linear-gradient(to right,red,blue) 0 0/0 0;
color:#fff;
border-radius:50px;
position:relative;
z-index:0;
transition:1s all;
}
.button:before,
.button:after{
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
background-image:inherit;
border-radius:inherit;
transition:1s all;
}
.button:before {
-webkit-mask:
linear-gradient(#fff,#fff) top /100% 5px no-repeat,
linear-gradient(#fff,#fff) bottom/100% 5px no-repeat,
radial-gradient(farthest-side at left,transparent calc(100% - 6px), #fff calc(100% - 5px)) right/27px 100% no-repeat,
radial-gradient(farthest-side at right,transparent calc(100% - 6px), #fff calc(100% - 5px)) left/27px 100% no-repeat;
mask:
linear-gradient(#fff,#fff) top /100% 5px no-repeat,
linear-gradient(#fff,#fff) bottom/100% 5px no-repeat,
radial-gradient(farthest-side at left,transparent calc(100% - 6px), #fff calc(100% - 5px)) right/27px 100% no-repeat,
radial-gradient(farthest-side at right,transparent calc(100% - 6px), #fff calc(100% - 5px)) left/27px 100% no-repeat;
}
.button:hover::after {
opacity:0;
}
.button:hover {
color:red;
}
body {
background:linear-gradient(to right,gray,white)
}
<div class="button"> some text</div>
Тот же трюк с использованием SVG:
.button {
display:inline-block;
margin:10px;
padding:5px;
font-size:25px;
width:250px;
text-align:center;
line-height:1.8;
background:linear-gradient(to right,red,blue) 0 0/0 0;
color:#fff;
border-radius:50px;
position:relative;
z-index:0;
transition:1s all;
}
.button:after{
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
background-image:inherit;
border-radius:inherit;
transition:1s all;
}
.button:hover::after {
opacity:0;
}
.button:hover {
color:red;
}
.hide {
height:0;
width:0;
}
.button svg {
position:absolute;
top:0;
left:0;
height:100%;
width:100%;
z-index:-1;
}
body {
background:linear-gradient(to right,gray,white)
}
<svg class="hide" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="Gradient" x1="0" x2="250" y1="0" y2="0" gradientUnits="userSpaceOnUse"><stop stop-color="red" offset="0"/><stop stop-color="blue" offset="1"/></linearGradient></defs><rect x="3" y="3" width="100%" height="100%" id="border" style="height:calc(100% - 6px);width:calc(100% - 6px)" rx="25" ry="25" stroke-width="5" fill="transparent" stroke="url(#Gradient)"/></svg>
<div class="button">
<svg xmlns="http://www.w3.org/2000/svg">
<use href="#border" />
</svg>
some text</div>