You could use border-top-left-radius and [border-top-right-radius][1] properties to round the corners on the box according to the box's height (and added borders).
Then add a border to top/right/left sides of the box to achieve the effect.
Here you go:
.half-circle {
width: 200px;
height: 100px; /* as the half of the width */
background-color: gold;
border-top-left-radius: 110px; /* 100px of height + 10px of border */
border-top-right-radius: 110px; /* 100px of height + 10px of border */
border: 10px solid gray;
border-bottom: 0;
}
[1]: https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-right-radius
You could use [`border-top-left-radius`][1] and [`border-top-right-radius`][2] properties to round the corners on the box according to the box's height (and added borders).
Then add a border to top/right/left sides of the box to achieve the effect.
Here you go:
<!-- language: lang-css -->
.half-circle {
width: 200px;
height: 100px; /* as the half of the width */
background-color: gold;
border-top-left-radius: 110px; /* 100px of height + 10px of border */
border-top-right-radius: 110px; /* 100px of height + 10px of border */
border: 10px solid gray;
border-bottom: 0;
}
**[WORKING DEMO][3]**.
Alternatively, you could add [`box-sizing: border-box`][4] to the box in order to calculate the width/height of the box including borders and padding.
<!-- language: lang-css -->
.half-circle {
width: 200px;
height: 100px; /* as the half of the width */
border-top-left-radius: 100px;
border-top-right-radius: 100px;
border: 10px solid gray;
border-bottom: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
**[UPDATED DEMO][5]**. *(**[Demo][6]** without background color)*
[1]: https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-left-radius
[2]: https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-right-radius
[3]: http://jsfiddle.net/hashem/u78bQ/
[4]: https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing
[5]: http://jsfiddle.net/hashem/u78bQ/1/
[6]: http://jsfiddle.net/hashem/u78bQ/2/