Cut Corners using CSS

后端 未结 15 1188
悲&欢浪女
悲&欢浪女 2020-11-22 03:34

I\'m looking to \"cut\" the top left corner of a div, like if you had folded the corner of a page down.

I\'d like to do it in pure CSS, are there any methods?

15条回答
  •  -上瘾入骨i
    2020-11-22 04:01

    You can use clip-path, as Stewartside and Sviatoslav Oleksiv mentioned. To make things easy, I created a sass mixin:

    @mixin cut-corners ($left-top, $right-top: 0px, $right-bottom: 0px, $left-bottom: 0px) {
      clip-path: polygon($left-top 0%, calc(100% - #{$right-top}) 0%, 100% $right-top, 100% calc(100% - #{$right-bottom}), calc(100% - #{$right-bottom}) 100%, $left-bottom 100%, 0% calc(100% - #{$left-bottom}), 0% $left-top);
    }
    
    .cut-corners {
      @include cut-corners(10px, 0, 25px, 50px);
    }
    
    

提交回复
热议问题