CSS Transform to skew the shape to a trapezium

前端 未结 2 558
北海茫月
北海茫月 2020-12-15 05:22

I want to be able to skew an element in the way the image displays below.

\"rhombus\"

I have been play

2条回答
  •  旧时难觅i
    2020-12-15 06:08

    You can apply some rotate transform around the X axis and apply an appropriate pespective before:

    div {    
      width:300px;
      height:200px;
      background:url(http://placekitten.com/300/200);
      border:2px solid red;    
      border-top-width:4px;
      border-bottom-width:1px;
      -webkit-transform: perspective(200px) rotateX(40deg);    
      margin:100px;
    }
    

    Demo

提交回复
热议问题