绘制四分之一圆、半圆、椭圆、半椭圆(向上)

绘制圆角矩形

    <style>
        .box{
            width: 300px;
            height: 300px;
            background-color: pink;
            border: 1px solid black;
            margin: 30px auto;
            border-top-left-radius: 300px;
        }
    </style>
</head>
<body>
    <div class="box box1"></div>
</body>

效果:

半圆

    <style>
         .box{
            width: 300px;
            /* height: 150px;半圆 height: 300px;正圆 */
            height: 150px;
            background-color: skyblue;
            border: 1px solid black;
            margin: 30px auto;
            border-top-left-radius: 150px;
            border-top-right-radius: 150px;
         }
    </style>
</head>
<body>
    <div class="box box1"></div>
</body>

 效果:

CSS3: border-radius绘制椭圆

语法:

border-radius: 1-4 length|% / 1-4 length|%;

一般写法: border-radius: 50%;

等价于: border-radius: 50% 50% 50% 50% / 50% 50% 50% 50%; (左上,右上,右下,左下)

"/"之前的四个数值表示圆角的水平半径,后面四个值表示圆角的垂直半径。

绘制椭圆

    <style>
        .box{
            width: 500px;
            height: 300px;
            background-color: pink;
            /* 椭圆 */
            /* 250px --水平半径(是盒子宽度的一半)*/
            /* 150px --垂直半径(是盒子高度的一半) */
            /* border-radius: 250px/150px; */


            /* 50% -- 水平半径 (是盒子宽度的50%)*/
            /* 50% -- 垂直半径 (是盒子高度的50%) */
            border-radius: 50%/50%;
        }
    </style>
</head>
<body>
    <div class="box box1"></div>
</body>

 预览:

 绘制半椭圆(向上)

    <style>
        .box{
            width: 500px;
            height: 150px;
            background-color: yellow;
            margin-top: 200px;
            /* 半椭圆 */
            border-radius: 50% 50% 50% 50%/0 0 100% 100%;
        }
    </style>
</head>
<body>
    <div class="box box1"></div>
</body>

 预览:

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值