像这样吗?http://codepen.io/anon/pen/VvqRep
.rectangle{
display:block;
height:40px;
width:150px;
background:red;
position:relative;
margin-top:100px;
}
.circle{
position:absolute;
height:40px;
width:40px;
border-radius:40px;
border:3px solid white;
left:50%;
margin-left:-25px;
top: -20px;
background:red;
}
通过在圆形周围使用边框,可以实现“截止”效果。
如果我的回答对您有帮助,请选择它吗?谢谢。
.rectangle{
display:block;
height:50px;
width:150px;
background:red;
position:relative;
margin-top:100px;
border-top-left-radius: .5em;
border-top-right-radius: .5em;
}
.circle{
position:absolute;
height:40px;
width:40px;
border-radius:40px;
border:3px solid white;
left:50%;
margin-left:-25px;
top: -20px;
background:red;
}
看这个 :)
.base{
height:80px;
width:300px;
background:#d33;
position:relative;
margin-top:100px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
.circle{
position:absolute;
height:100px;
width:100px;
border-radius:50%;
border:3px solid white;
left:50%;
margin-left:-55px;
top: -40px;
background: #d33;
}
<div class="base">
<div class="circle"></div>
</div>
请使用以下html和css代码:
CSS:
#rectangle {
width:300px;
height:70px;
position: relative;
background: #cc0000;
border-radius: 5px 5px 0 0;
}
#rectangle #circle {
width:70px;
height:70px;
position: absolute;
top:-35px;
background:#cc0000;
border:1px solid #fff;
border-radius:70px;
left: 50%;
margin-left: -35px;
}
HTML:
<div id="rectangle">
<div id="circle"></div>
</div>
#bg {
position: relative;
background: red;
width: 200px;
height: 50px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
margin-top: 50px;
}
#circle {
position: absolute;
background: red;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
top: -50px;
width: 75px;
height: 75px;
border: 3px solid #fff;
border-radius: 50%;
}
<div id="bg">
<div id="circle"></div>
</div>