turning an image into css

前端 未结 8 1804
一生所求
一生所求 2021-01-16 03:59

I have this image (attached). I am not a designer but I do not want to use the image in my app. I heard you can come very close to an image using css. Can someone help me wi

8条回答
  •  遥遥无期
    2021-01-16 04:33

    I've yet to see an approach using pseudo elements here, so I thought I'd add one here. This is presuming that you're giving your div a set height:

    div{
      height:50px;
      width:200px;
      position:relative;
      margin-left:25px;
      background:tomato;
      }
    
    div:before{
      content:"";
      position:absolute;
      top:0;
      left:-25px;
      border-top:25px solid tomato;
      border-left:25px solid transparent;
      }
    
    
    div:after{
      content:"";
      position:absolute;
      bottom:0;
      left:-25px;
      border-bottom:25px solid tomato;
      border-left:25px solid transparent;
      }

提交回复
热议问题