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

最终效果如下所示

代码在这儿:
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:
二:在上面的圆角矩形左右各加一个蓝色色的圆角矩形,与上下两个矩形相切,但是长度和宽度都不能超过上下两个大矩形

三:再在后来添加的小蓝色矩形块儿上,各增加一个大小一致的白色矩形覆盖,分别设置右下圆角与左下圆角,代码如下:
border-radius: 0 0 20px 0; border-radius: 0 0 0 20px;
OK,大功告成!一个凸型框就制作好啦。
感谢各位的阅读!看完上述内容,你们对css如何实现凸字形状大概了解了吗?希望文章内容对大家有所帮助。如果想了解更多相关文章内容,欢迎关注创新互联成都网站设计公司行业资讯频道。
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。