Featured image of post border-radius 边框圆角详解

border-radius 边框圆角详解

基本语法

border-radius : none | <length>{1,4} [/ <length>{1,4} ]?

<length>: 由浮点数字和单位标识符组成的长度值。不可为负值。

如果你在 border-radius 属性中只指定一个值,那么将生成 4 个圆角。

但是,如果你要在四个角上一一指定,可以使用以下规则:

  • 四个值:第一个值为左上角,第二个值为右上角,第三个值为右下角,第四个值为左下角
  • 三个值:第一个值为左上角, 第二个值为右上角和左下角,第三个值为右下角
  • 两个值:第一个值为左上角与右下角,第二个值为右上角与左下角
  • 一个值:四个圆角值相同

示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!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>border-radius</title>
    <style>
      body {
        background-color: black;
      }

      .wrapper {
        width: 40%;
        display: flex;
        flex-wrap: wrap;
      }

      div[class*="box"] {
        display: flex;
        align-items: center;
        width: 100px;
        height: 100px;
        margin: 0 20px;
      }

      .box1 {
        border-radius: 10px;
        background-color: brown;
      }

      .box2 {
        border-radius: 10px 20px;
        background-color: yellow;
      }

      .box3 {
        /* 左上角 (右上角,左下角) 右下角 */
        border-radius: 10px 20px 30px;
        background-color: blueviolet;
      }

      .box4 {
        border-radius: 10px 20px 30px 40px;
        background-color: burlywood;
      }

      .box5 {
        border-radius: 10px / 40px;
        background-color: cornflowerblue;
      }

      .box6 {
        border-radius: 10px 20px / 30px 40px;
        background-color: crimson;
      }

      .box7 {
        /* border-radius: 50px; */
        border-radius: 55px;
        background-color: cadetblue;
        border: 5px solid green;
      }

    </style>
  </head>

  <body>
    <div class="wrapper">
      <div class="box1">border-radius: 10px</div>
      <div class="box2">border-radius: 10px 0px</div>
      <div class="box3">border-radius: 10px 20px 30px</div>
      <div class="box4">border-radius: 10px 20px 30px 40px</div>
      <div class="box7">border-radius: 50px</div>

      <div class="box5">border-radius: 10px / 20px</div>
      <div class="box6">border-radius: 10px 20px / 30px 40px</div>
    </div>
  </body>

</html>

效果如下

参考

comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计