Cutting image diagonally with CSS

前端 未结 5 1476
不思量自难忘°
不思量自难忘° 2020-12-15 20:40

How to cut away part of an image or container diagonally using CSS?

The part that needs to be cut away has the form of a triangle

5条回答
  •  北海茫月
    2020-12-15 20:43

    Use CSS3 -clip-path and polygon like this. You can specify whatever path you want to.

    img {
      width: 100px;
      height: 100px;
      -webkit-clip-path: polygon(0 0, 0 100px, 100px 80px, 100px 0);
      clip-path: polygon(0 0, 0 100px, 100px 80px, 100px 0);
    }

    http://jsfiddle.net/r3p9ph5k/

    For some extra bits you might want to take a look at e.g. this. Also, for more information about IE, see this.

提交回复
热议问题