JSFiddle - React, Tailwind, and code Playground

HTML

<h1 class=" titre"> Un titre de longueur variable</h1>
<h1 class="titre"> Un titre de longueur variable</h1>
<h1 class=""> Un titre de longueur variable</h1>

CSS

.titre {
  font-size: 34px;
  padding: 0.5em;
  background: lightgray;
}

h1.titre:before {
  content: '';
  display: block;
  width: max-content;
  padding: 0.45rem;
  border-radius: 50%;
  background: red;
  box-shadow: 1rem 0 green, 2rem 0 yellow;
  margin-bottom: 1rem;
}


h1:nth-child(2n):before {
  content: '';
  display: block;
  width: max-content;
  padding: 0.45em;
  border-radius: 50%;
  background: red;
  box-shadow: 1em 0 green, 2em 0 yellow;
  margin-bottom: 1em;
}

h1:nth-child(2n):before {
  filter: drop-shadow(calc(100vw - 5em) 2em)
}