[英]achieving rounded corners for button with border-image-source is linear gradient
I want to achieve rounded corners for button while using border-image-source to linear gradient. 我想在使用border-image-source到线性渐变时实现按钮的圆角。
snippet is below - 片段如下-
button-class :card-approve-btn 按钮类:card-approve-btn
CSS:- CSS: -
.card-approve-btn {
width: 85px;
height: 30px;
text-align: center;
color: #485564;
font-size: 14px;
line-height :10px;
font-weight: 600;
border-radius: 6px;
background-color: #ffffff;
border-style: solid;
border-width: 1px;
border-image-source: linear-gradient(291deg, #ffb37c, #f9514f);
border-image-slice: 1;
}
using above css is resulting in edgy corners. 使用以上CSS会导致前卫角。 and, after googling, i got to know that it is not possible to have both border radius and linear-gradient. 并且,在使用谷歌搜索之后,我知道不可能同时具有边界半径和线性渐变。 Is it Really Impossible? 真的不可能吗? If No, Then please suggest if anyone has answers. 如果否,那么请建议是否有人回答。
You can apply the gradient as the main background then use a pseudo element above it to hide it and keep only the border part visible: 您可以将渐变作为主要背景,然后在其上方使用伪元素将其隐藏,并仅保留边界部分可见:
.card-approve-btn { position: relative; display:inline-block; background-image: linear-gradient(291deg, #ffb37c, #f9514f); padding:0 20px; line-height:30px; text-align: center; color: #485564; border-radius: 6px; overflow: hidden; font-size: 14px; font-weight: 600; z-index:0; } .card-approve-btn:before { content: ''; position: absolute; /* specify the value of border width here */ top: 1px; right: 1px; bottom: 1px; left: 1px; /* --- */ background-color: #fff; border-radius: 5px; box-sizing: border-box; z-index: -1; }
<div class="card-approve-btn"> Approve </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.