I'm trying to achieve this effect for a button:
I've been battling it for a couple hours and the best I could come up with was this CodePen.
<a href="#" class="btn-wrap">
<span class="btn btn-primary">See the Proof</span>
</a>
.btn {
border: 0;
border-radius: 0;
font-weight: 300;
font-size: 20px;
text-transform: uppercase;
}
.btn-primary {
position: relative;
-webkit-transition: all .2s ease;
-moz-transition: all .2s ease;
transition: all .2s ease;
}
.btn-primary:before, .btn-primary:after {
position: absolute;
content: '';
right: -20px;
width: 10px;
height: 50%;
background: inherit;
}
.btn-primary:before {
top: 0;
transform: skewX(30deg);
}
.btn-primary:after {
bottom: 0;
transform: skewX(-30deg);
}
.btn-wrap {
position: relative;
display: inline-block;
}
.btn-wrap:before, .btn-wrap:after {
position: absolute;
content: '';
right: -40px;
width: 10px;
height: 50%;
background: #337ab7;
-webkit-transition: all .2s ease;
-moz-transition: all .2s ease;
transition: all .2s ease;
}
.btn-wrap:hover:before, .btn-wrap:hover:after {
background: #23527c;
}
.btn-wrap:before {
top: 0;
transform: skewX(30deg);
}
.btn-wrap:after {
bottom: 0;
transform: skewX(-30deg);
}
I want to ensure it works well responsively, so if the text breaks to 2 lines, the arrows maintain full height.
Any thoughts?
Using SVG
clipPath
along with the CSSclip-path
property we can create a path such that it cuts out the unwanted portions from the button (thea
tag).Pros:
body
or the parent has a non-solid background.Cons:
clip-path
in any version of IE including Edge. Support forclip-path
in Edge is Under consideration and may get implemented in future.Check this solution this uses a
pseudo-element
to create the right first triangle and two skewed pseudo-elements to create the extending parts,box-shadow
is used to recreate themtry to combine it with that code:
that is a triangle.
Hope I could help.
Devlen