我可以用css制作这个形状吗?
.shape {
margin: 40px;
height: 40px;
width: 100px;
border-radius: 50px;
background: #333;
position: relative;
}
.shape:before {
height: 80px;
width: 80px;
border-radius: 100%;
content: '';
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background: #333;
}

<div class="shape"></div>
&#13;
答案 0 :(得分:3)
这就是你要找的东西
.shape {
margin: 40px;
height: 40px;
width: 110px;
border-radius: 50px;
background: #333;
position: relative;
}
.shape:before {
height: 80px;
width: 80px;
border-radius: 100%;
content: '';
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background: #333;
}
.shape:after {
height: 40px;
width: 121px;
border-radius: 90%;
content: '';
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background: #333;
}
<div class="shape"></div>
答案 1 :(得分:1)
所以,你有三个组件,你已经使用普通的CSS和其他(circle
)使用before
选择器。现在,使用after
选择器创建第三个组件。
.shape {
margin: 40px;
height: 40px;
width: 155px;
border-radius: 50px;
background: #333;
position: relative;
}
.shape:after {
height: 55px;
width: 135px;
border-radius: 20px;
content: '';
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background: #333;
}
.shape:before {
height: 100px;
width: 100px;
border-radius: 100%;
content: '';
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background: #333;
}
&#13;
<div class="shape"></div>
&#13;
答案 2 :(得分:0)
此代码可能会对您有所帮助。
这是CSS。
*
{
margin: 0px;
padding: 0px;
}
.circle
{
position: relative;
height: 300px;
background: #000;
border-radius: 50%;
border-color: #000;
position: absolute;
top: 50px;
left:100px;
}
.top
{
width: 358px;
height: 115px;
background: #000;
border-radius: 54px;
position: absolute;
top:86px;
left: -28px;
}
.hor
{
width: 400px;
height: 50px;
background: #000;
border-radius: 50px;
position: absolute;
top:117px;
left:-50px;
}
这是相应的HTML。
<div class="page">
<div class="circle">
<div class="top"></div>
<div class="hor"></div>
</div></div>