边框圆角(圆、半圆、四分之一圆)的设置

<style>

        div.first {

            width: 200px;

            height: 200px;

            background-color: lightcoral;

            border-radius: 20px 40px 60px 80px;

            /* 左上 右上/左下 右下  */

            border-radius: 20px 40px 60px;

            /* 左上/右下 右上/左下 */

            border-radius: 20px 40px;

            /* border-radius: 10px 0 0 10px; */

            border-bottom-left-radius: 50px;

        }

        .second {

            width: 100px;

            height: 100px;

            background-color: pink;

            /* 元素本身宽高的百分比 */

            border-radius: 50%;

        }

        .third {

            width: 100px;

            height: 50px;

            background-color: blue;

            border-radius: 50px 50px 0 0;

        }

        .four {

            width: 100px;

            height: 100px;

            background-color: aqua;

            border-radius: 0 0 100% 0;

        }

    </style>

</head>

<body>

    <!--

        border-radius:设置边框圆角

         取值:

           四个值:左上角 右上角 右下角 左下角

           三个值:左上角 右上角/左下角 右下角

           二个值:左上角/右下角 右上角/左下角

     -->

    <!--

        设置圆:1.设置元素宽高比1:1,2.设置边框弧度时宽高的一半 (可以使用具体的数值或者百分比)

        设置半圆:1.确定半圆=》确定元素的宽高比,2.确定哪二个角要设置,设置值为圆的半径,具体的值

        设置四分之一圆:1.确定四分之一圆,元素的宽高比1:1,

                      2.确定哪个角要设置,设置值为圆的半径,元素的宽高(可以使用具体的数值或者百分比)

      -->

    <div class="first"></div>

    <!-- 设置圆 -->

    <div class="second"></div>

    <!-- 设置二分之一圆---上半圆 -->

    <div class="third"></div>

    <br><br><br>

    <!-- 设置四份之一圆---右下 -->

    <div class="four"></div>

   

</body>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1. 形: 使用 CSS3 的 border-radius 属性,将宽高设置为相等的值即可创建形。 示例代码: ```css .circle { width: 100px; height: 100px; border-radius: 50%; } ``` 2. 环: 在形的基础上,添加 border 属性控制边框宽度和颜色。 示例代码: ```css .ring { width: 100px; height: 100px; border-radius: 50%; border: 10px solid #000; } ``` 3. 半圆: 使用 CSS3 的 border-radius 属性,将宽度设置为高度的两倍,再设置 border-bottom-left-radiusborder-bottom-right-radius 的值为 0,即可创建半圆。 示例代码: ```css .half-circle { width: 100px; height: 50px; border-radius: 100px 100px 0 0; } ``` 4. 四分之一: 在半圆的基础上,再设置 border-top-left-radius 的值为 0,即可创建四分之一。 示例代码: ```css .quarter-circle { width: 50px; height: 50px; border-radius: 0 50px 0 0; } ``` 5. 扇形: 在形的基础上,使用伪元素 ::before 和 ::after 创建两个三角形,再使用 transform 属性旋转其中一个三角形,即可创建扇形。 示例代码: ```css .sector { position: relative; width: 100px; height: 100px; border-radius: 50%; overflow: hidden; } .sector::before, .sector::after { content: ""; position: absolute; top: 0; left: 0; width: 50%; height: 100%; background-color: #000; transform-origin: 100% 50%; } .sector::before { transform: rotate(30deg); } ``` 以上是几种常见的 CSS3 形、环、半圆四分之一、扇形的实现方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值