【问题标题】:is there have any way to put gradient in stroke?有没有办法在中风中加入渐变?
【发布时间】:2020-11-10 20:27:05
【问题描述】:

有什么方法可以在笔画中添加渐变吗?

body {background-color:black;}

.couponimg_box {
  background-color:black;
  width:60%;
  height:550px;
  display:inline-block;
  border-radius:15px;
  margin-top:80px;
  transition: all 1s;
}
         
.btn rect {
  fill: none;
  stroke: yellow;
  stroke-width: 2;
  stroke-dasharray: 422, 0;
  -webkit-transition: all 0.35s linear;
  transition: all 0.35s linear;
  opacity:0;  
}

.btn:hover rect {
  stroke-width: 5;
  stroke-dasharray: 15, 310;
  stroke-dashoffset: 48;
  -webkit-transition: all 1.35s cubic-bezier(0.19, 1, 0.22, 1);
  transition: all 1.35s cubic-bezier(0.19, 1, 0.22, 1);
  animation: stop 1.5s ease-in-out 1;
  opacity:0;
}
  
@keyframes stop {
  0% {
    opacity:1;
  }
  25% {
    opacity:1;
  }
  100% {
    opacity:0;
  }
}
<div id="coupon_box" clss="couponimg_box">
  <a href="https://twitter.com/Dave_Conner" class="btn btn-1">
    <svg>
    <rect x="0" y="0" fill="none" width="100%" height="100%"/>
    </svg>
    Hover1
  </a>
</div>

当我搜索时,人们习惯在背景上放置一个渐变,其中包含 btn 内容 但是,我想知道是否可以在笔画中使用渐变色而不是“黄色(单色)”

任何帮助将不胜感激!谢谢! :D

【问题讨论】:

  • 请同时添加html代码..
  • 我只是编辑它并放入html代码! :)

标签: html css svg


【解决方案1】:

您已在 SVG 中的某处定义了线性渐变。

body {background-color:black;}

.couponimg_box { 
  background-color:black;
  width:60%;
  height:550px;
  display:inline-block;
  border-radius:15px;
  margin-top:80px;
  transition: all 1s;
}

.btn rect {
  fill: none;
  //stroke: yellow;
  stroke-width: 2;
  stroke-dasharray: 422, 0;
  -webkit-transition: all 0.35s linear;
  transition: all 0.35s linear;
  opacity:0;
}

.btn:hover rect {
  stroke-width: 5;
  stroke-dasharray: 15, 310;
  stroke-dashoffset: 48;
  -webkit-transition: all 1.35s cubic-bezier(0.19, 1, 0.22, 1);
  transition: all 1.35s cubic-bezier(0.19, 1, 0.22, 1);
  animation: stop 1.5s ease-in-out 1;
  opacity:0;
}

@keyframes stop {
  0% {
    opacity:1;
  }
  25% {
    opacity:1;
  }
  100% {
    opacity:0;
  }
}
<div id="coupon_box" clss="couponimg_box">
    <a href="https://twitter.com/Dave_Conner" class="btn btn-1">
      <svg>
        <defs>
          <linearGradient id="gradient" x1="0%" y1="0%" x2="0%" y2="100%">
            <stop offset="0%" stop-color="#00bc9b" />
            <stop offset="100%" stop-color="#5eaefd" />
          </linearGradient>
        </defs>
        <rect x="0" y="0" fill="none" width="100%" height="100%" stroke="url(#gradient)" stroke-width="2" fill="none"/>
      </svg>
        Hover1
    </a>
</div>

【讨论】:

  • omg....你是我的救星...非常感谢!!!!祝你有美好的一天!!! :D
猜你喜欢
  • 2014-07-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-10-15
  • 1970-01-01
  • 2019-12-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多