Znalostní bázeCentrum zkoušek
CSČeština
Vybrat jazyk13

CKTIS / CSS

corner-shape — tvar rohů

corner-shape vybírá geometrii rohů v oblasti vymezené vlastností border-radius. Bez nenulového poloměru nemá viditelný účinek.

Verze: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntaxe

corner-shape: <corner-shape-value>{1,4};
<corner-shape-value> = round | scoop | bevel | notch | square | squircle | superellipse(<number> | infinity | -infinity)

corner-shape je zkrácený zápis, který nastavuje tvary čtyř rohů. Výchozí hodnota je round; vlastnost se nedědí. Velikost rohů neurčuje — k tomu slouží border-radius.

Jedna hodnota platí pro všechny rohy; dvě hodnoty platí pro protilehlé dvojice; tři hodnoty platí pro levý horní roh, pravý horní/levý dolní roh a pravý dolní roh. Čtyři hodnoty se uvádějí po směru hodinových ručiček od levého horního rohu.

Dostupné hodnoty zahrnují round, squircle, square, bevel, scoop, notch a superellipse(K). Klíčová slova odpovídají postupně hodnotám K 1, 2, infinity, 0, -1 a -infinity. bevel vytváří rovnou úhlopříčku; scoop a notch vytvářejí konkávní výřezy.

Příklad je třeba ověřit místně. Rozsah Chromium 152 nenahrazuje kontrolu vykreslení.

Příklady

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>corner-shape on all four corners</title>
  <style>
    .tile {
      width: 160px;
      height: 100px;
      background: teal;
      border-radius: 24px;
      corner-shape: bevel;
    }
  </style>
</head>
<body>
  <div class="tile" role="img" aria-label="Teal tile used to test corner-shape on all four corners"></div>
  <script>
    if (CSS.supports('corner-shape', 'bevel')) {
      console.log('corner-shape: supported');
      const style = getComputedStyle(document.querySelector('.tile'));
      for (const corner of ['top-left', 'top-right', 'bottom-right', 'bottom-left']) {
        const computed = style.getPropertyValue(`corner-${corner}-shape`);
        const shape = computed === 'superellipse(0)' ? 'bevel' : computed;
        const radius = style.getPropertyValue(`border-${corner}-radius`);
        console.log(`${corner}: ${shape}, radius ${radius}`);
      }
    } else {
      console.log('corner-shape: unsupported');
    }
  </script>
</body>
</html>

Výsledek

corner-shape: supported
top-left: bevel, radius 24px
top-right: bevel, radius 24px
bottom-right: bevel, radius 24px
bottom-left: bevel, radius 24px

Zobrazený kód a uvedený výsledek byly ověřeny v izolovaném prostředí metodou zaznamenanou v dokladu o ověření této přesné verze.

Zdroje