css切角效果,多角,折角效果

本文详细介绍如何使用CSS实现复杂的背景渐变效果,包括线性渐变和径向渐变的多种应用,以及如何通过Sass混合器简化代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文作者: 吼吼酱
原文:链接

html

<div class="one">12345</div>
<div class="two">abcde</div>

css

.one{
    height: 200px;
    width: 200px;
    margin: 10px auto;
    line-height: 200px;
    background: yellowgreen;
    background: 
              linear-gradient(-45deg,transparent 15px, yellowgreen 0)bottom right,
              linear-gradient(-135deg,transparent 15px, yellowgreen 0)top right,
              linear-gradient(135deg,transparent 15px, yellowgreen 0)top left,
              linear-gradient(45deg,transparent 15px, yellowgreen 0)bottom left;
              background-size: 50% 50%;
              background-repeat: no-repeat;
  }
  .two{
    height: 200px;
    width: 200px;
    margin: 10px auto;
    background: #58a;
    line-height: 200px;
    background: 
              radial-gradient(circle at bottom right,transparent 15px, #58a 0)bottom right,
              radial-gradient(circle at top right,transparent 15px, #58a 0)top right,
              radial-gradient(circle at top left,transparent 15px, #58a 0)top left,
              radial-gradient(circle at bottom left,transparent 15px, #58a 0)bottom left;
              background-size: 50% 50%;
              background-repeat: no-repeat;
  }

acss的也可以这样写

@mixin current_color($bg,$tr){
  background: $bg;
  background: 
              linear-gradient(-45deg,transparent $tr, $bg 0)bottom right,
              linear-gradient(-135deg,transparent $tr, $bg 0)top right,
              linear-gradient(135deg,transparent $tr, $bg 0)top left,
              linear-gradient(45deg,transparent $tr, $bg 0)bottom left;
              background-size: 50% 50%;
              background-repeat: no-repeat;
}
.one{
    height: 200px;
    width: 200px;
    margin: 10px auto;
    line-height: 200px;
    @include current_color(yellowgreen,15px)
  }

如图效果
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值