css切角效果,折角效果


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)
  }

如圖效果


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM