纯CSS实现花括号 ‘{‘ (一)

先展示最终效果

在这里插入图片描述

前言

今天群内有人说像这样的花括号怎么实现在这里插入图片描述
我就用微信截图给他简单画了一下实现思路,如下图:
在这里插入图片描述
过了一会他用另一个思路也实现了,如下图:
在这里插入图片描述
就是放大文本嘛,不好看,不好看
我就决定自己写一个

version 1

通过好几个矩形实现的,很复杂还不好看,不好看
在这里插入图片描述

最终版本

注:可使用动态样式 来调整花括号的宽高
在这里插入图片描述

代码如下:

<style>
    * {
      padding: 0;
      margin: 0;
    }

    .box {
      padding: 100px;
      width: 100px;
      height: 200px;
    }
      /* border: 1px solid #956e6e; */

    .TTT{
      height: 15px;
    }
    .base{
      height: 100px;
      width: 30px;
      position: relative;
      box-sizing: border-box;
    }
    .t{
      background-color: antiquewhite;
      border-bottom-right-radius: 30px;
      border: 1px solid #000;
      border-top: none;
      border-left: none;
      &:before{
        content: '';
        height: 30px;
        width: 30px;
        background-color: rgb(248, 165, 57);
        position: absolute;
        right: -31px;
        top: -30px;
        border: 1px solid #000;
        border-top-left-radius: 100%;
        border-right:none;
        border-bottom:none;
      }
    }
    .b{
      margin-top: -1px;
      background-color: rgb(220, 196, 164);
      border-top-right-radius: 30px;
      border: 1px solid #000;
      border-bottom: none;
      border-left: none;
      &:before{
        content: '';
        height: 30px;
        width: 30px;
        background-color: rgb(248, 165, 57);
        position: absolute;
        right: -31px;
        bottom: -30px;
        border: 1px solid #000;
        border-bottom-left-radius: 100%;
        border-top: none;
        border-right: none;
      }
    }
  </style>
</head>

<body>

  <div class="box">
    <div class="base t">
    </div>
    <div class="base b">
    </div>
  </div>

</body>

最后:喜欢的同学,记得点赞关注哦!

兄弟们 有后续 :
纯CSS实现花括号 ‘{‘ (二)(自适应内容高度) https://blog.youkuaiyun.com/weixin_45856516/article/details/137347812

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值