CSS Transform to skew the shape to a trapezium

前端 未结 2 554
北海茫月
北海茫月 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条回答
  •  温柔的废话
    2020-12-15 05:55

    Try this:

    Html

    StyleSheet

    .trapezium {
        border-bottom: 80px solid #fff;
        border-left: 45px solid transparent;
        border-right: 45px solid transparent;
        padding: 0 8px 0 0;
        height: 0;
        width: 120px;
        position: relative;
        margin: 2em auto;
    }
    
    .trapezium:before {
        border-bottom: 90px solid #000;
        border-left: 50px solid transparent;
        border-right: 50px solid transparent;
        padding: 0 8px 0 0;
        height: 0;
        width: 130px;
        position: absolute;
        bottom: -85px;
        left: -55px;
        content: "";
        z-index: -1;
    }
    

    Here is the Demo

提交回复
热议问题