css—圆角渐变边框+透明背景色

<script>
import { css } from 'vue-styled-components'
const style = css`
  padding:100px;
  background: #222;

  .test{
    cursor: pointer;
    position: relative;
    width: 180px;
    height: 60px;
    margin-bottom: 20px;
    margin-right: 20px;
    font-size: 15px;
    color: #e2fffd;
    transition: all 0.5s ease-in-out;
    text-align:center;
    line-height:60px;
  }

  .test{
    --border-radius: 10px;
    --border-width: 1px;
    --border-color: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.4));
    width: 200px;
    height: 80px;
    position: relative;
    color: #fff;
    border-radius: var(--border-radius);
    background: linear-gradient( 180deg, rgba(255,255,255,0.06) 0%, rgba(248,250,252,0.34) 100%);
    box-shadow: inset 0px 2px 5px 0px rgba(255,255,255,0.42);
    backdrop-filter: blur(10px);
  }

  .test::after{
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    padding: var(--border-width);
    border-radius: var(--border-radius);
    background: var(--border-color);
    /* 随便定义一个颜色 */
    --mask-bg: linear-gradient(red, red);
    /* 类似background-clip */
    --mask-clip: content-box, padding-box;
    /* mask允许使用者通过遮罩或者裁切特定区域的图片的方式来隐藏一个元素的部分或者全部可见区域 */
    /* mask-image类似background-image 设置了用作元素蒙版层的图像,默认值为none,值为透明图片,或透明渐变 */
    -webkit-mask-image: var(--mask-bg), var(--mask-bg);
    /* 默认值为border-box,可选值与background-origin相同 */
    -webkit-mask-clip: var(--mask-clip);
    /* exclude排除,只显示不重合的地方,Firefox支持4个属性 */
    mask-composite: exclude;
    /* 只显示下方遮罩,重合的地方不显示 */
    -webkit-mask-composite: destination-out;
  }
`
export default {
  data () {
    return {

    }
  },
  render () {
    return (
      <div v-css={style}>
        <div class="test test_1">mask</div>
        <div class="test test_2">背景透明</div>
      </div>
    )
  },
}
</script>

效果图如下: 

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值