How can I create Triangle shape clip mask using CSS

前端 未结 4 1558
面向向阳花
面向向阳花 2021-01-18 18:45

I want to create triangle as shown in image. Does someone know how to achieve the effect?

\"enter

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-18 19:28

    Imagine the area with photo is split down the middle into two squares, with the photo as a background.

    Now imagine you give those squares very thick top and bottom borders with colours corresponding to the areas above and below the photo.

    Now imagine you also give them a very thick border for each of their adjacent sides (the left square has a right border, the right square has a left border), but this time, you make the border transparent.

    You will see that where the top/bottom borders and the side borders meet, there is a diagonal edge between them where the colour changes to transparent. This leaves a transparent triangle in the adjacent corners where the background shows through.

提交回复
热议问题