純css實現卡券式半圓及陰影(整理)


<!-- html部分 -->
<div class="a">
  <!-- a這個大卡片里邊分上下兩個卡片,對應上邊灰色和下邊白色部分 -->
  <div class="b"></div>
  <div class="c"></div>
</div>
/* css部分 */
body{
  background:#F0AE80
}
.a{
  /*用於實現缺口那的陰影,用box-shadow缺口那會有問題*/
  filter:drop-shadow(1px 1px 5px #000);
}
.b{
  width:200px;
  height:100px;
  /*通過radial-gradient,用徑向漸變創建 "圖像"*/
  /*定義了形狀:圓形,位置:左下角,顏色:透明,半徑:10,背景色:f5f5f5,背景位置:左右各一個*/
  background:radial-gradient(circle at bottom left,transparent 10px, #f5f5f5 0) left,
    radial-gradient(circle at bottom right,transparent 10px, #f5f5f5 0) right;
  /*對應上面左右各一個,這里把背景橫向平分50%*/
  background-size:50% 100%;
  /*必須設置否則去掉上面某些樣式,會有多個透明扇形出現*/
  background-repeat:no-repeat;
  border-radius:10px;
}
/*下面部分同理*/
.c{
  width:200px;
  height:200px;
  background:radial-gradient(circle at top left,transparent 10px, #fff 0) left,
    radial-gradient(circle at top right,transparent 10px, #fff 0) right;
  background-size:50% 100%;
  background-repeat:no-repeat;
  border-radius:10px;
}

可自行添加兼容性


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM