Transparent arrow/triangle indented over an image

后端 未结 4 505
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 02:06

I would like to make a transparent arrow over an image. This triangle should be indented in a semi transparent block and show the background image.

4条回答
  •  借酒劲吻你
    2020-11-22 02:47

    Here is a solution using CSS clip-path that doesn't overflow the wrapper.

    .wrap {
      position:relative;
      width:480px;
      height:270px;
      background-image:url(http://placehold.it/480x270);
    }
    
    .wrap:after {
      content:"";
      display:block;
      position:absolute;
      left:0;
      right:0;
      bottom:0;
      height:50px;
      background-color:rgba(0, 0, 0, 0.7);
      -webkit-clip-path:polygon(0 0, calc(50% - 30px) 0, 50% 50%, calc(50% + 30px) 0, 100% 0, 100% 100%, 0 100%);
      -moz-clip-path:polygon(0 0, calc(50% - 30px) 0, 50% 50%, calc(50% + 30px) 0, 100% 0, 100% 100%, 0 100%);
      clip-path:polygon(0 0, calc(50% - 30px) 0, 50% 50%, calc(50% + 30px) 0, 100% 0, 100% 100%, 0 100%);
    }

提交回复
热议问题