0

As usual, the question indicated as a duplicate has outdated or incoherent answers

This question is about SVGs

I'm not interested by "hacks" with box shadows or pseudo elements, they multiply tech debt and always end up posing other problems


I'm trying to create a shape to be used with clip-path on buttons and dialogs

The shape is fairly simple:

enter image description here

However, when applied to rectangular buttons, the edges get scaled down (as they should). Making it look wrong :

enter image description here

Ideally, I would want this path to scale like this :

enter image description here

Is it possible to give a fixed position to path curves but not its lines ?

.svg {
  position: absolute;
  width: 0;
  height: 0;
}
.clipped {
  height: 3rem;
  background-color: green;
  color: white;
  border: none;
  clip-path: url(#my-clip-path);
}
<svg class="svg">
  <clipPath id="my-clip-path" clipPathUnits="objectBoundingBox"><path d="M0,0.1 v0.8 c0.05,0,0.1,0.05,0.1,0.1 h0.8 c0,-0.05,0.05,-0.1,0.1,-0.1 v-0.8 C0.95,0.1,0.9,0.05,0.9,0 h-0.8 C0.1,0.06,0.05,0.1,0,0.1"></path></clipPath>
</svg>

<button class="clipped">Some rectangular button</button>

4
  • 1
    This is an article about how to do it using css: css-tricks.com/scooped-corners-in-2018 Also take a look at this dabblet (Lea Verou) dabblet.com/gist/10168919
    – enxaneta
    Commented Apr 30 at 17:48
  • css-generators.com/custom-corners/#2 Commented Apr 30 at 20:50
  • Is your question really about SVGs, or is it about the best way to achieve a particular visual effect? As regards SVG, no, you cannot scale some parts of it but not others. SVG is not the right tool to solve this problem. The link @TemaniAfif posted is great, but #1 might be all you need, and it doesn't require a pseudo-element. #2 does require a pseudo-element, but there is no logical reason to avoid pseudo-elements. Commented May 2 at 0:54
  • @BrettDonald and I already provided an answer in the duplicate (you voted to reopen) using those links as well: stackoverflow.com/a/73510336/8620333 Commented May 2 at 7:32

0

Browse other questions tagged or ask your own question.