Cut Corners using CSS

后端 未结 15 1520
悲&欢浪女
悲&欢浪女 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条回答
  •  庸人自扰
    2020-11-22 04:00

    This code allows you to cut corners on each side of the rectangle:

    div {
      display:block;
      height: 300px;
      width: 200px;
      background: url('http://lorempixel.com/180/290/') no-repeat;
      background-size:cover;
    
      -webkit-clip-path: polygon(10px 0%, calc(100% - 10px) 0%, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0% calc(100% - 10px), 0% 10px);
      clip-path: polygon(10px 0%, calc(100% - 10px) 0%, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0% calc(100% - 10px), 0% 10px);
    }
    

    http://jsfiddle.net/2bZAW/5552/

提交回复
热议问题