CSS 实现半圆/三角形

2021-05-24  本文已影响0人  my木子

半圆

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  /* 上半圆 */
  .semi-circle1 {
    width: 100px;
    height: 50px;
    background-color: #cb18f8;
    border-radius: 50px 50px 0 0;
    /* 左上、右上、右下、左下 */
  }

  /* 下半圆 */
  .semi-circle2 {
    width: 100px;
    height: 50px;
    background-color: #cb18f8;
    border-radius: 0 0 50px 50px;
    /* 左上、右上、右下、左下 */
  }

  /* 左半圆 */
  .semi-circle3 {
    width: 50px;
    height: 100px;
    background-color: #cb18f8;
    border-radius: 50px 0 0 50px;
    /* 左上、右上、右下、左下 */
  }

  /* 右半圆 */
  .semi-circle4 {
    width: 50px;
    height: 100px;
    background-color: #cb18f8;
    border-radius: 0 50px 50px 0;
    /* 左上、右上、右下、左下 */
  }
</style>

<body>
  <div class="parent">
    <div class="semi-circle1"></div>
    <div class="semi-circle2"></div>
    <div class="semi-circle3"></div>
    <div class="semi-circle4"></div>
  </div>
</body>

</html>

三角形

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  div {
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-bottom: 100px solid pink;
  }
</style>

<body>
  <div></div>
</body>

</html>
上一篇下一篇

猜你喜欢

热点阅读