css(画三角形,画圆)

150 阅读1分钟

1.画三角形 注意:宽高给0px,其他三个边框颜色调为透明

<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>

    <style>
        div {
            width: 0;
            height: 0;
            border: 50px solid transparent;
            border-top: 50px solid yellow;
        }
    </style>
</head>
<body>
    <div></div>
</body>
</html>

运行图:

image.png

2.画圆 注意:宽和高一定要相等,然后边框给50%

<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>

  <style>
    .father{
      margin: 30px auto;
      width: 300px;
      height: 300px;
      border-radius: 50%;
      background-color: yellow;
    }

  </style>
</head>
<body>
  
  <div class="father">
  </div>
</body>
</html>

运行图:

image.png