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;
    }
  }
}
相关推荐
parade岁月21 小时前
Tailwind CSS v4 — 当框架猜不透你的心思
前端·css
前端Hardy1 天前
HTML&CSS&JS:基于定位的实时天气卡片
javascript·css·html
程序员阿耶1 天前
5 个让 CSS 起飞的新特性,设计师看了直呼内行
css
前端Hardy1 天前
HTML&CSS:纯CSS实现随机转盘抽奖机——无JS,全靠现代CSS黑科技!
css·html
DeathGhost1 天前
分享URL地址到微信朋友圈没有缩略图?
前端·html
漂流瓶jz2 天前
BEM、OOCSS、SMACSS、ITCSS、AMCSS、SUITCSS:CSS命名规范简介
前端·css·代码规范
前端Hardy2 天前
HTML&CSS:高颜值产品卡片页面,支持主题切换
css·html
Never_Satisfied2 天前
在HTML & CSS中,nth-child、nth-of-type详解
前端·css·html
光影少年2 天前
前端css如何实现水平垂直居中?
前端·javascript·css
你怎么知道我是队长2 天前
前端学习---HTML---块元素和行内元素
前端·学习·html