html - 有没有办法在中风中加入渐变?
问题描述
有没有办法在笔划中添加渐变?
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
解决方案
您已经在 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>
推荐阅读
- python - 尝试使用 element.text 从网页获取多个文本字段
- javascript - 设备上的本机后退按钮从中间页面重定向回来
- python - 我必须在屏幕中间制作一个字母金字塔我能够打印金字塔但似乎无法获得字母并进入
- python - 如何将 SQL 命令语句作为参数传递给另一个函数
- angular - 带有 ViewChildren 的 ExpressionChangedAfterItHasBeenCheckedError
- php - 注意:未定义变量:第 16 行 /Applications/XAMPP/xamppfiles/htdocs/menthor/login.php 中的电子邮件
- python - 如何在python中解析一个jsonify对象并在html中显示?
- memory-leaks - 有没有一种惯用的方法来避免使用此代码“Box::leak”?
- python - 如何在辅助函数中使用固定装置?
- php - 是否可以从多个表中的多个值创建单个 url?