Cutting image diagonally with CSS

前端 未结 5 1482
不思量自难忘°
不思量自难忘° 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 21:06

    Just an idea:

    HTML

    CSS

    figure {
        position: relative;
        display: inline-block;
        overflow: hidden;
        padding: 0;
        line-height: 0;
    }
    
    figure:after {
        content: '';
        position: absolute;
        width: 200%;
        height: 100%;
        left: 0;
        bottom: -91%;
        background: red;
        -webkit-transform: rotate(355deg);
        transform: rotate(355deg);
    }
    

    Demo

    Try before buy

提交回复
热议问题