Reputation: 1
What I need is:
So, my main questions are:
.btn-default {
border-radius: 22px;
text-transform: uppercase;
border: solid 2px;
}
.btn-default:hover {
opacity: 0.5;
}
.btn-filled{
background: linear-gradient(180deg, #BC9CFF 0%, #8BA4F9 100%);
color: #FFFFFF;
border-color: transparent;
}
.btn-outline {
position:relative;
box-sizing: border-box;
background-clip: padding-box;
border: transparent;
color: #BC9CFF;
background: white;
}
.btn-outline:before {
content:'';
position: absolute;
top:0px; right:0px; bottom:0px; left: 0px;
background: linear-gradient(180deg, #BC9CFF 0%, #8BA4F9 100%);
z-index: -1;
margin: -2px;
border-radius: inherit;
}
<!-- button A -->
<button type="button" name="button" class="btn-default btn-outline">click me</button>
<!-- button B -->
<button type="button" name="button" class="btn-default btn-filled">click me</button>
Upvotes: 0
Views: 332
Reputation: 23280
Separate the hover conditions to target the :before
pseudo element on the outline like this.
.btn-default,
.btn-outline{
border-radius: 22px;
text-transform: uppercase;
border: solid 2px;
}
.btn-default:hover {
opacity: 0.5;
}
.btn-outline:hover:before {
opacity: .5;
}
.btn-filled{
background: linear-gradient(180deg, #BC9CFF 0%, #8BA4F9 100%);
color: #FFFFFF;
border-color: transparent;
}
.btn-outline {
position:relative;
box-sizing: border-box;
background-clip: padding-box;
border: transparent;
color: #BC9CFF;
background: white;
}
.btn-outline:before {
content:'';
position: absolute;
top:0px; right:0px; bottom:0px; left: 0px;
background: linear-gradient(180deg, #BC9CFF 0%, #8BA4F9 100%);
z-index: -1;
margin: -2px;
border-radius: inherit;
}
<!-- button A -->
<button type="button" name="button" class="btn-outline">click me</button>
<!-- button B -->
<button type="button" name="button" class="btn-default btn-filled">click me</button>
Upvotes: 0