<ul>
  <li>
    <div class="block" data-position="top">top</div>
  </li>
  <li>
    <div class="block" data-position="right">right</div>
  </li>
  <li>
    <div class="block" data-position="bottom">bottom</div>
  </li>
  <li>
    <div class="block" data-position="left">left</div>
  </li>
  <li>
    <div class="block" data-position="lower-left">lower-left</div>
  </li>
  <li>
    <div class="block" data-position="upper-left">upper-left</div>
  </li>
  <li>
    <div class="block" data-position="lower-right">lower-right</div>
  </li>
  <li>
    <div class="block" data-position="upper-right">upper-right</div>
  </li>
</ul>

:root {
  --clip-triangle-top: polygon(50% 0, 100% 100%, 0 100%);
  --clip-triangle-bottom: polygon(0 0, 100% 0, 50% 100%);
  --clip-triangle-right: polygon(0 0, 100% 50%, 0 100%);
  --clip-triangle-left: polygon(0 50%, 100% 0, 100% 100%);
  --clip-triangle-lower-left: polygon(0 0, 100% 100%, 0 100%);
  --clip-triangle-upper-left: polygon(0 0, 100% 0, 0 100%);
  --clip-triangle-lower-right: polygon(100% 0, 100% 100%, 0 100%);
  --clip-triangle-upper-right: polygon(0 0, 100% 0, 100% 100%);

  --c-white: #f7f7f7;
  --c-primary: #cd5c5c;
}

*,
::before,
::after {
  box-sizing: border-box;
}

body {
  padding: max(5vi, 16px);
  font-family: 'Open Sans', sans-serif;
  font-size: 1em;
  line-height: 1.5;
  background-color: var(--c-white);
}

ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
  max-inline-size: 1200px;
  margin: auto;
}

li {
  display: grid;
  place-items: center;
  padding: 16px;
}

.block {
  position: relative;
  min-inline-size: 196px;
  padding-block: 1.2em;
  padding-inline: 1.5em;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--c-white);
  text-align: center;
  background-color: var(--c-primary);
  border-radius: 4px;
  box-shadow: 0 10px 12px -8px rgb(0 0 0 / 35%);

  &::after {
    --size: 16px;
    position: absolute;
    content: '';
  }
}

[data-position='top']::after {
  inline-size: var(--size);
  block-size: calc(var(--size) / 2 * tan(60deg));
  inset-block-end: 100%;
  inset-inline-start: 0;
  inset-inline-end: 0;
  margin-inline: auto;
  clip-path: var(--clip-triangle-top);
  background-color: var(--c-primary);
}

[data-position='bottom']::after {
  inline-size: var(--size);
  block-size: calc(var(--size) / 2 * tan(60deg));
  inset-block-start: 100%;
  inset-inline-start: 0;
  inset-inline-end: 0;
  margin-inline: auto;
  clip-path: var(--clip-triangle-bottom);
  background-color: var(--c-primary);
}

[data-position='right']::after {
  inline-size: calc(var(--size) / 2 * tan(60deg));
  block-size: var(--size);
  inset-block-start: 0;
  inset-block-end: 0;
  inset-inline-start: 100%;
  margin-block: auto;
  clip-path: var(--clip-triangle-right);
  background-color: var(--c-primary);
}

[data-position='left']::after {
  inline-size: calc(var(--size) / 2 * tan(60deg));
  block-size: var(--size);
  inset-block-start: 0;
  inset-block-end: 0;
  inset-inline-end: 100%;
  margin-block: auto;
  clip-path: var(--clip-triangle-left);
  background-color: var(--c-primary);
}

[data-position='lower-left']::after {
  inline-size: var(--size);
  aspect-ratio: 1;
  inset-block-end: 4px;
  inset-inline-start: 4px;
  margin-block: auto;
  clip-path: var(--clip-triangle-lower-left);
  background-color: currentcolor;
}

[data-position='upper-left']::after {
  inline-size: var(--size);
  aspect-ratio: 1;
  inset-block-start: 4px;
  inset-inline-start: 4px;
  margin-block: auto;
  clip-path: var(--clip-triangle-upper-left);
  background-color: currentcolor;
}

[data-position='lower-right']::after {
  inline-size: var(--size);
  aspect-ratio: 1;
  inset-block-end: 4px;
  inset-inline-end: 4px;
  margin-block: auto;
  clip-path: var(--clip-triangle-lower-right);
  background-color: currentcolor;
}

[data-position='upper-right']::after {
  inline-size: var(--size);
  aspect-ratio: 1;
  inset-block-start: 4px;
  inset-inline-end: 4px;
  margin-block: auto;
  clip-path: var(--clip-triangle-upper-right);
  background-color: currentcolor;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.