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;
    }
  }
}
相关推荐
心中无石马5 小时前
uniapp引入tailwindcss4.x
前端·css·uni-app
小小码农Come on6 小时前
QML访问子项内容
前端·javascript·html
幽络源小助理7 小时前
小六壬排盘工具源码 自适应双端 纯原生HTML+JS
前端·javascript·html
Championship.23.248 小时前
Open Source Pipeline Skill深度解析:自动化开源贡献全流程
前端·javascript·html
用户059540174469 小时前
asyncio 踩坑实录:这个问题坑了我3小时,差点让线上服务崩掉
前端·css
凯瑟琳.奥古斯特10 小时前
Bootstrap快速上手指南
开发语言·前端·css·bootstrap·html
Dxy123931021611 小时前
HTML中的Canvas可以干哪些事情
前端·html
悟乙己11 小时前
解析 Agent 时代的 HTML PPT SKILLS: html-ppt-skill
前端·html·powerpoint
ZC跨境爬虫11 小时前
跟着 MDN 学 HTML day_2:(表单分组与高级输入控件实战)
前端·javascript·css·ui·html
Dxy123931021613 小时前
HTML中使用Canvas动态图形渲染:解锁Web交互新维度
前端·html·图形渲染