具有边框半径和渐变文本的渐变边框

naz*_*hid 3 css linear-gradients

我正在努力实现以下设计!我已经设法用渐变边框实现边框半径,但如果我尝试使用-webkit-background-clip&-webkit-text-fill-color作为渐变文本,则边框半径不起作用,整个按钮都会获得渐变颜色。我使用作为渐变文本的参考并附加渐变边框的代码

带有渐变边框的 CSS 渐变文本

.btn {
  background-image: linear-gradient(to right, #006175 0%, #00a950 100%);
  border-radius: 40px;
  box-sizing: border-box;
  color: #00a84f;
  display: block;
  font: 1.125rem 'Oswald', Arial, sans-serif;
  /*18*/
  height: 80px;
  letter-spacing: 1px;
  margin: 0 auto;
  padding: 4px;
  position: relative;
  text-decoration: none;
  text-transform: uppercase;
  width: 264px;
  z-index: 2;
}

.btn:hover {
  color: #fff;
}

.btn span {
  align-items: center;
  background: #e7e8e9;
  border-radius: 40px;
  display: flex;
  justify-content: center;
  height: 100%;
  transition: background .5s ease;
  width: 100%;
}

.btn:hover span {
  background: transparent;
}
Run Code Online (Sandbox Code Playgroud)
<a class="btn" href="#">
  <span>Click Here!</span>
</a>
Run Code Online (Sandbox Code Playgroud)

任何形式的帮助将不胜感激!请随时提出一些建议。TIA

Tem*_*fif 8

我将考虑之前的答案来使用伪元素构建圆角渐变,以便您可以background-clip:text在主元素上使用。我已经使用了 mask 版本,你也可以考虑 SVG 版本:

.btn {
  --r:40px; /* radius */
  --b:5px; /* border width */
  
  background: linear-gradient(to right, #006175 0%, #00a950 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 1.5rem 'Oswald', Arial, sans-serif;
  height: 80px;
  margin: 0 auto;
  position: relative;
  z-index:0;
  text-decoration: none;
  width: 264px;
}
/* check lined question for the detail of the below code */
.btn::before {
  content:"";
  position:absolute;
  z-index:-1;
  inset: 0;
  border: var(--b) solid transparent;
  border-radius: var(--r);
  background: inherit;
  background-origin: border-box;
  background-clip: border-box;
  -webkit-mask:
    linear-gradient(#fff 0 0) padding-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  -webkit-mask-repeat: no-repeat;
}
/**/
.btn:hover {
  color: #fff;
  -webkit-text-fill-color: #fff;
  -webkit-background-clip: border-box;
  background-clip: border-box;
}

.btn:hover::before {
  -webkit-mask:none;
}

body {
  background:pink;
}
Run Code Online (Sandbox Code Playgroud)
<a class="btn" href="#">
  Click Here!
</a>
Run Code Online (Sandbox Code Playgroud)