<div class="card" style="--clr: #249eff">
<div class="box">
<div class="icon">
<div class="icon_box">div>
div>
<div class="content">div>
div>
div>
.container .card {
position: relative;
width: 300px;
height: 460px;
background: var(--clr);
border-radius: 20px;
border-top-left-radius: 70px;
overflow: hidden;
}
/* 定位在背景上,并且使用inset属性设置四周间距,从而形成边框 */
.container .card .box {
position: absolute;
inset: 10px;
background: #282828;
border-radius: 10px;
}
/* 设置图标容器样式 */
.container .card .box .icon {
position: absolute;
width: 140px;
height: 140px;
background: var(--clr);
border-bottom-right-radius: 50%;
}
实现思路就是在icon
的容器中添加一个伪元素,伪元素使用box-shadow
属性进行弯曲部分的实现,如下图橙色框框出的部分,我们只要设置对应的颜色就可以,形成图标部分左下角的弯曲部分。
.container .card .box .icon::before {
content: "";
position: absolute;
bottom: -30px;
left: 0;
width: 30px;
height: 30px;
background: transparent;
border-top-left-radius: 30px;
box-shadow: -5px -5px 0 5px var(--clr);
}
实现思路跟左下角部分实现思路一样。
.container .card .box .icon::after {
content: "";
position: absolute;
top: 0px;
right: -30px;
width: 30px;
height: 30px;
background: transparent;
border-top-left-radius: 30px;
box-shadow: -5px -5px 0 5px var(--clr);
}
.container .card .box .icon .icon_box {
position: absolute;
inset: 10px;
background: #282828;
border-radius: 50%;
border-top-right-radius: 10px;
border-bottom-left-radius: 10px;
}
<div class="icon_box">
<i class="fa-solid fa-code">i>
div>
.container .card .box .icon .icon_box {
position: absolute;
inset: 10px;
background: #282828;
border-radius: 50%;
border-top-right-radius: 10px;
border-bottom-left-radius: 10px;
display: flex;
justify-content: center;
align-items: center;
font-weight: 600;
}
.container .card .box .icon .icon_box i {
font-size: 2.5em;
color: #fff;
}
.container .card .box .content {
position: absolute;
top: 150px;
padding: 20px;
text-align: center;
}
.container .card .box .content h2 {
color: #fff;
font-size: 1.35em;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.12em;
}
.container .card .box .content p {
color: #fff;
font-size: 0.95em;
opacity: 0.75;
margin: 0 0 10px;
}
.container .card .box .content a {
background: var(--clr);
display: inline-block;
padding: 10px 25px;
text-decoration: none;
color: #333;
text-transform: uppercase;
font-weight: 600;
border-radius: 30px;
transition: 0.5s;
}
.container .card .box .content a:hover {
letter-spacing: 0.2em;
}