css如何实现凸字形状

发布时间:2020-10-22 15:57:51 作者:小新
来源:亿速云 阅读:170

css如何实现凸字形状?这个问题可能是我们日常学习或工作经常见到的。希望通过这个问题能让你收获颇深。下面是小编给大家带来的参考内容,让我们一起来看看吧!

最终效果如下所示

css如何实现凸字形状

代码在这儿:

   <div class="box">
        <span class="big"></span>
        <span class="top"></span>
        <span class="topR"></span>
    </div>
body {
            display: flex;
            justify-content: center;
            align-items: center;
        
        
        .box {
            position: relative;
            width: 400px;
            height: 400px;
            top: 200px;
            color: lightblue;
       
        
        .big {
            position: absolute;
            width: 400px;
            height: 200px;
            border-radius: 20px;
            background-color: currentColor;
            bottom: 0;
        }
        
        .top {
            position: absolute;
            width: 100px;
            left: calc((400px - 100px)/2);
            height: 150px;
            border-radius: 20px 20px 0 0;
            background-color: currentColor;
            top: 50px;
        }
        
        .top::before {
            content: "";
            position: absolute;
            background-color: lightblue;
            height: 48px;
            width: 100px;
            left: -100px;
            top: 102px;
        }
        
        .top::before {
            content: "";
            position: absolute;
            background-color: lightblue;
            height: 48px;
            width: 100px;
            left: -100px;
            top: 102px;
        }
        
        .top::after {
            content: "";
            position: absolute;
            background-color: #fff;
            border-radius: 0 0 20px 0;
            height: 48px;
            width: 100px;
            left: -100px;
            top: 102px;
        }
        
        .topR {
            position: absolute;
            background-color: lightblue;
            height: 48px;
            width: 100px;
            right: 50px;
            top: 152px;
        }
        
        .topR::after {
            content: "";
            position: absolute;
            background-color: #fff;
            border-radius: 0 0 0 20px;
            height: 48px;
            width: 100px;
            left: 0;
            top: 0;
        }
   }
}

一开始我以为只要上下两个圆角矩形拼接就行,NO NO NO,其实两个圆角相交处还有圆角,一看这个圆角就知道,可以使用白色的圆角矩形覆盖,那么问题来了:
白色的圆角矩形覆盖之后,中间会形成空隙,这个空隙需要蓝色填满。所以思路是这样的:

一、先建立上下两个圆角矩形:
HTML:

 <span class="big"></span>
 <span class="top"></span>

二:在上面的圆角矩形左右各加一个蓝色色的圆角矩形,与上下两个矩形相切,但是长度和宽度都不能超过上下两个大矩形

css如何实现凸字形状

三:再在后来添加的小蓝色矩形块儿上,各增加一个大小一致的白色矩形覆盖,分别设置右下圆角与左下圆角,代码如下:

border-radius: 0 0 20px 0;
border-radius: 0 0 0 20px;

OK,大功告成!一个凸型框就制作好啦。

感谢各位的阅读!看完上述内容,你们对css如何实现凸字形状大概了解了吗?希望文章内容对大家有所帮助。如果想了解更多相关文章内容,欢迎关注亿速云行业资讯频道。

推荐阅读:
  1. CSS怎么实现鼠标光标形状的变化
  2. 怎么用clip-path实现CSS形状变换

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

css 如何实现

上一篇:阿里云服务器网速好慢这么解决

下一篇:h5 canvas实现粒子时钟的案例

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》