css实现文字和边框同样的渐变色效果

话不多说,直接上代码

实现的效果

js 复制代码
<div className="button">
  <div className="box">
     <div className="title">
       渐变色文字
     </div>
   </div>
</div>
css 复制代码
.button {
   	border-radius: 20px;
    background-image: linear-gradient(105deg, #3A82FD 0%, #15C6FF 100%);
    padding: 1px;
    display: inline-block;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
  .box{
    height: 100%;
    border-radius: 20px;
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;

    .title{
      font-size: 12px;
      line-height: 20px;
      background: linear-gradient(102deg, #1C6CF6 0%, #15E0FF 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      text-fill-color: transparent;
    }
  }
}
相关推荐
会编程的土豆1 天前
新手前端小细节
前端·css·html·项目
周航宇JoeZhou1 天前
JB2-7-HTML
java·前端·容器·html·h5·标签·表单
代码小库1 天前
【课程作业必备】Web开发技术HTML静态网站模板 - 校园动漫社团主题完整源码
前端·html
云计算DevOps-韩老师1 天前
HTML 中的行级元素(inline)、块级元素(block)、行内块元素(inline-block)
html
珹洺1 天前
Bootstrap-HTML(二)深入探索容器,网格系统和排版
前端·css·bootstrap·html·dubbo
BillKu1 天前
VS Code HTML CSS Support 插件详解
前端·css·html
咔咔一顿操作1 天前
轻量无依赖!autoviwe 页面自适应组件实战:从安装到源码深度解析
javascript·arcgis·npm·css3·html5
HetFrame1 天前
一种纯前端实现 Markdown 内容即时分享的思路
html·react·链接·markdown·工具
1024小神1 天前
用css的clip-path裁剪不规则形状的图片展示
前端·css
GGGG寄了1 天前
CSS——文字控制属性
前端·javascript·css·html