Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a half circle at the bottom middle of my header?

Here is how I want it to look:

header with half circle at bottom

I realize this is an ugly mockup and obviously when I do it for real the proportions will look better, but I am wondering how you would go about doing this with CSS.

fiddle is here http://jsfiddle.net/bU3QS/1/

<div class="header">
    </div>

.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #000;
    z-index: 10000;
    height: 110px;
    overflow: hidden;
}
like image 757
steveai Avatar asked Feb 15 '23 16:02

steveai


1 Answers

Use the :after pseudo element:

.header:after {
    content: '';
    position: absolute;
    background: black;
    width: 50px;
    height: 50px;
    z-index: 1;
    border-radius: 50%;    /* Makes the element circular */
    bottom: -25px;
    left: 50%;
    margin-left: -25px;
}

For this solution, overflow: hidden; has been removed from the .header CSS.

Here's a fiddle: http://jsfiddle.net/t97AX/

Here's another approach, that doesn't rely on the width of the semicircle to center it properly:

.header:after {
    content: '';
    position: relative;
    top: 100%;
    display: block;
    margin: 0 auto;
    background: red;
    width: 50px;
    height: 25px;
    border-radius: 0 0 50px 50px;
}

The fiddle (semicircle red for the sake of clarity): http://jsfiddle.net/x4mdC/

More on :before and :after: http://www.w3.org/TR/CSS2/selector.html#before-and-after

like image 80
Nicklas Nygren Avatar answered Feb 27 '23 09:02

Nicklas Nygren