Half hexagon shape with one element

后端 未结 5 2050
青春惊慌失措
青春惊慌失措 2020-11-30 13:30

I\'m trying to replicate the following shape with no success:

\"enter

I\'m gue

5条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 13:50

    See a demo - basically it uses css triangles and a pseudo element to give a place for the triangle.

    .shape {
        position: relative;
        width: 78px;
        height:30px;
        background:#3a93d0;
    }
    
    .shape:after {
        content: '';
        display: block;
        position: absolute;
        top: 100%;
        width: 0;
        height: 0;
        border-style: solid;
        border-width: 25px 39px 0 39px;
        border-color: #3a93d0 transparent transparent transparent;
    }
    

提交回复
热议问题