I'm creating a website, with a header / menu on top. In the middle, there is a logo. To accentuate this, I've absolute positioned an ellips below the logo: So underneath, you see the ellips, which blends in perfectly with the rest of the menu.
.ellips {
border-radius: 50%;
height: 130%;
background: white;
left: 0px;
right: 0px;
z-index: 1;
position: absolute;
top: 6%;
border: 2px solid #dfe0e4;
}
Now the client wants to see the left and right 'corner' also curved:
I know that the 'shove an ellips beneath the menu' approach won't suffice. I was thinking about 2 possible solutions:
Create an SVG with the curve, and place it beneath the menu. I've tried that solution, but I'm no SVG expert, so I went to try a CSS approach:
Try to create CSS item (div) with such curve: above it's white, below it's transparent. Put dat item below the menu.
I prefer a css solution, as I'm no big hero in SVG. But if it can be achieved much easier with SVG. Then I'd take that solution off course.
Edit: The blue-ish background you see, is an underlaying image. So this needs to be transparant.
The ellips needs to be colored white.
I created 2
SVG
examples so you can choose where to apply the backgroundThe outer container of each
SVG
element keeps a specific aspect ratio so the whole element can be responsive (but, of course, you can also specify a fixed width or height).The basic idea is to create a
path
that overflows the size of theSVG
element, so you can define a closed shape on the top area or on the bottom area, in order to fill it with a colour (if you enlarged theviewbox
e.g. to-10 -10 610 130
you could see how the path is actually defined).The applied background is a gradient but you can also specify a single color-stop (white, in your specific scenario). The background on the body element shows the transparent parts of the
SVG
.Fine tuning and adjustment of curves, viewbox, colours is left to the reader.
For any change to the shape you can read the path documentation on MDN
Markup
CSS
Final Result
SVG would be the way to go for such things but for a CSS solution I would probably use multiple background with linear/radial-gradient BUT the drawback is that it can be difficult to calculate the different values and make the whole shape responsive.
Here is an example that can help you get some idea:
And if you are open to use multiple element you can rely on pseudo element and some border-radius but you have also to manage a lot of element:
And here is an SVG solution:
Here is an inline-SVG solution with a quadratic bezier curve.
The svg image has 500x50 pixels dimensions and is absolute positioned into the header.
Almost there ... it could get you in the way.
I used
::before
and::after
on the header to add two curve.Play a little with the values of the radius to get what you want.
The ellips has a fixed width, so this is as responsive as possible. When resizing the screen, the corners won't break but the ellip's size won't change.