帶有透明半圓切口的 Div
P粉022285768
P粉022285768 2023-10-22 17:51:09

我想只用 CSS3 來製作一個透明的切出半圓形形狀。唯一的要求是形成形狀的所有元素必須是黑色或透明

不能使用上面有一個白色圓圈的黑色矩形,因為半圓必須是透明的並讓背景顯示出來。

所需形狀:

P粉022285768
P粉022285768

全部回覆(2)
P粉138871485

您可以使用盒子陰影來製作透明剪切圓

body {
  background: url(http://i.imgur.com/qi5FGET.jpg) no-repeat;
  background-size: cover;
}
div {
  display: inline-block;
  width: 300px; height: 300px;
  position: relative;
  overflow: hidden;
}
div:before {
  content: '';
  position: absolute;
  bottom: 50%;
  width: 100%; height: 100%;
  border-radius: 100%;
  box-shadow: 0px 300px 0px 300px #000;
}
.transparent {
  opacity: 0.5;
}

這可以是具有百分比長度的響應式

body {
  background: url(http://lorempixel.com/output/people-q-c-640-480-1.jpg) no-repeat;
  background-size: cover;
}
div {
  width: 40%; height: 300px;
  position: relative;
  overflow: hidden;
}
div:before {
  content: '';
  position: absolute;
  bottom: 50%;
  width: 100%; height: 100%;
  border-radius: 100%;
  box-shadow: 0px 300px 0px 300px #000;
}
.transparent {
  opacity: 0.5;
}
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!