简单页面效果 自定义圆角 (不用border-radius)

64 阅读1分钟

思路:在正方形的一角(如:左上角),做一个圆形,然后做个给圆形做阴影盖住正方形的角,看上去就是圆角了

image.png

<!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>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    body{
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
    }
    .content{
      position: relative;
      width: 200px;
      height: 200px;
      background-color: red;
    }
    /* .content::before{
      content: "";
      position: absolute; 
      background-color: transparent;
      width: 30px;
      height: 30px;
      border-radius: 50%;
      box-shadow: -10px -10px 0 white; 
    } */
    .radius{
      position: absolute; 
      background-color: transparent;
      width: 30px;
      height: 30px;
      border-radius: 50%;
      box-shadow: -10px -10px 0 white; 
    }
  </style>
</head>
<body>
  <div class="content">
    <div class="radius"></div>
  </div>
</body>
</html