Clip path inset circle?

前端 未结 6 1284
北荒
北荒 2020-11-28 14:56

Is it possible to create an inset circle clip path so that the clip path would effectively cut a hole through the div in the center opposed to only showing the center?

6条回答
  •  难免孤独
    2020-11-28 15:00

    You could also do this with box-shadow on :after pseudo-element

    div {
      position: relative;
      width: 300px;
      height: 200px;
      overflow: hidden;
      background: url('http://planetcompas.com/live/wp-content/uploads/2013/04/2015-01-Beautiful-Planet-And-Space-4-Cool-Wallpapers-HD.jpg');
      background-size: cover;
      background-position: center;
    }
    div:after {
      width: 50px;
      height: 50px;
      content: '';
      border-radius: 50%;
      background: transparent;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      box-shadow: 0px 0px 0px 300px lightblue;
      transition: all 0.3s linear;
    }
    div:hover:after {
      opacity: 0;
    }

提交回复
热议问题