I want to design a shape as similar as the following image(effect between circle and rectangle):
I know the circle shape is designed using border-radius and the rectangle like shape is designed with some unordered list having style display: block. But I can't understand how to keep the circle over rectangle so that it looks like that some portion of the rectangle is cut down by the circle in a circle shape ( white color space between circle and rectangle).
I have tried box-shadow, outline, overflow and etc, but it is not working.
Can anyone tell me how can I design a shape as like as the image?
- Thanks
Something like this? 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;
}
the "cut-off" effect is achieved using a border on the circle.
If my asnwser helped you out, can you please select it? thanks
you can try this one:
.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;
}
DEMO HERE
use this: html and css code:
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>