I’m working on a fixed bottom navigation bar at the bottom of the page. I want to add a curved shape (like a rounded “notch”) at the top center of this bar.
Example:
I’ve tried using a ::before pseudo-element to create the curve with border-radius, and it mostly works but solution is not ideal, z-index are not helping.
The tricky part: I need the border of the curve to blend smoothly with the bar’s border, so it looks like one continuous border (even when the theme changes, like in .root_inverted). Also, I want the actual content inside the bar to stay unaffected—meaning I don’t want to restructure or move the DOM around just to fit the curve.
I’m trying to keep this CSS-only.
Has anyone solved something similar before? I’d love to hear ideas or clever tricks.
For now will simply share the small portion of CSS, because hope that somebody saw something similar or knows what I'm asking for. If it's not enough - will create the codepen demo.
Here's a simplified version of my SCSS:
.background {
position: fixed;
right: 0;
bottom: 0;
left: 0;
z-index: 10;
background: grey;
.root_inverted & {
background: red;
}
&::before {
content: '';
position: absolute;
top: -15px; // curve height
left: 50%;
transform: translateX(-50%);
width: 60px; // curve width
height: 30px;
border-top-left-radius: 30px;
border-top-right-radius: 30px;
background-color: grey;
border: 1px solid red;
border-bottom: none;
z-index: 1;
.root_inverted & {
background-color: yellow;
}
}
}
