Rounded trapezoid with CSS

后端 未结 5 1092
孤城傲影
孤城傲影 2020-12-11 21:31

I\'m having a slight problem with css. I need a trapezoid div which upper left corner(the one with the angle above 90 degrees) is rounded. I already know that this:

5条回答
  •  攒了一身酷
    2020-12-11 22:16

    Although I think you're better off using /SVG to draw this shape, this is close to what you want:

    .trapezoid{
        vertical-align: middle;
        border-bottom: 120px solid red;
        border-left: 200px solid transparent;
        border-top-left-radius:30px;
        height: 0;
        width: 150px;}
    
    /* ---------- */
    
    .trapezoid {
        position:relative;
    }
    .trapezoid:after {
        content:' ';
        left:-14px;
        top:-10px;
        position:absolute;
        background:red;
        border-radius:40px 0 0 0;
        width:164px;
        height:40px;
        display:block;
    }
    

    Demo: http://jsfiddle.net/n3TLP/20/

    It's not perfect, and you'll have to play with the numbers to get your desired dimensions, it's very finicky. You might be interested in something like Raphaël for drawing, CSS doesn't really have the capacity for complex shapes (at least not intentionally).

提交回复
热议问题