JSFiddle - React, Tailwind, and code Playground

Скругления, radial-gradient, прозрачное скругление. Для любой ширины ссылок

by Ankhena

HTML

<nav>

  <ul>
    <li><a href="">link</a></li>
    <li><a href="">link</a></li>
    <li><a class="active" href="">link link link</a></li>
    <li><a href="">link</a></li>
    <li><a href="">link</a></li>
  </ul>

</nav>

<p>У nav ограничена ширина для наглядности</p>
<p>Для <a href="https://qna.habr.com/q/901873">https://qna.habr.com/q/901873</a></p>

CSS

@import url('https://fonts.googleapis.com/css2?family=Neucha&display=swap');

:root {
  --radius: 30px;
  --smoothing-radius: 29.4px;
  --color: deeppink;
}
* {
  box-sizing: inherit;
}

html {
  box-sizing: border-box;
}

body {
  padding: 0 40px;
  margin: 0;
  font-family: 'Neucha', cursive;
}

nav {
  display: flex;
  justify-content: center;
}
nav {
  max-width: 90%;
  margin: auto;
  border-top: 10px solid var(--color); /*или включить в градиенты*/
  overflow: hidden;
}
ul {
  display: flex;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style-type: none;
}

nav a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(2 * var(--radius));
  padding: 0.5em 1em;
  font-weight: 400;
  font-size: 20px;
  text-decoration: none;
  white-space: nowrap;
  
  
}

.active::before {
  content: "";
  position: absolute;
  top: 0;
  right: calc(100% - var(--radius));
  display: block;
  width: 50vw;
  height: 100%;
  background:
    radial-gradient(at top left, var(--color) var(--smoothing-radius), transparent var(--radius)) no-repeat bottom 0 right var(--radius) / var(--radius) var(--radius),
    radial-gradient(at bottom right, transparent var(--smoothing-radius),  var(--color) var(--radius)) no-repeat top 0 right 0 / var(--radius) var(--radius),

  
    linear-gradient(to right,  var(--color),  var(--color)) no-repeat top 0 right var(--radius) / var(--radius) calc(100% - var(--radius)),
    linear-gradient(to left, transparent calc(2 * var(--radius)), var(--color) calc(2 * var(--radius))) no-repeat left / 100% 100%;
    z-index: -1;
    
}

.active::after {
  content: "";
  position: absolute;
  top: 0;
  left: calc(100% - var(--radius));
  display: block;
  width: 50vw;
  height: 100%;
  background:
    radial-gradient(at top right, var(--color) var(--smoothing-radius), transparent var(--radius)) no-repeat bottom 0 left var(--radius) / var(--radius) var(--radius),
    radial-gradient(at bottom left, transparent...