2021-02-09

1 篇文章 0 订阅

#css实现四条边有弧度的圆角矩形

直接上图。
在这里插入图片描述

那兄弟让我用css给它整出来。我*****
在这里插入图片描述

然后我就用border-radius:25%;做出来发现不对啊,四条边没弧度啊,这可不行。

最后我就发现了这种写法border-radius: 16px 16px 16px 16px/45px 45px 45px 45px; 得到了两条弧度边。

于是最后代码如下:

.box{
            margin: 30px 50px;
            position: relative;
            width: 96px;
            height: 80px;
            background-color: rgb(33, 149, 243);
            border-radius: 16px 16px 16px 16px/56px 56px 56px 56px;
            box-shadow: 0 0 15px 6px rgb(107, 107, 107);
            z-index:0;
        }
        .box::after{
            content: "";
            position:absolute;
            top: -8px;
            left: 8px;
            width: 80px;
            height: 96px;
            background-color: rgb(33, 149, 243);
            border-radius: 56px 56px 56px 56px/16px 16px 16px 16px;
            z-index:-1;
        }

        .box1{
            position: relative;
            width: 48px;
            height: 40px;
            background-color: rgb(255, 115, 1);
            border-radius: 8px 8px 8px 8px/20px 20px 20px 20px;
            box-shadow: 0 0 15px 2px rgb(107, 107, 107);
            z-index:0;
        }

        .box1::after{
            content: "";
            position:absolute;
            top: -4px;
            left: 4px;
            width: 40px;
            height: 48px;
            background-color: rgb(255, 115, 1);
            border-radius: 20px 20px 20px 20px/8px 8px 8px 8px;
            z-index:-1;
        }

最后的z-index属性,可写可不写,只是为了字能够显示出来。

html只需插入两个盒子即可:

<div class="box"></div>
<div class="box1"></div>

成品图片如下:
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值