遮罩渐变按钮

图片描述
这种按钮如何使用CSS来实现?

阅读 2k
2 个回答

代码/效果截图如下,兼容性未做。建议直接图片代替这种按钮。

<div class="button">确认</div>

.button {
  position: relative;
  width: 120px;
  height: 30px;
  color: #1e9cd8;
  border-radius: 16px;
  font-size: 18px;
  text-align: center;
  border: 4px solid transparent;
  background: #ffff;
  background-clip: padding-box;
}

.button::after {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: -4px;
  right: -4px;
  content: '';
  background: linear-gradient(90deg, #0379c2, #22dff3);
  z-index: -1;
  border-radius: 16px;
}

图片描述

建议图片,最简单,能兼容

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题