<div class="breadcrumb">
  <div>Irem 1</div>
  <div>another Irem</div>
  <div>Irem 3</div>
</div>
<div class="breadcrumb" style="border:5px;--a:15px;--gap:20px">
  <div>AA</div>
  <div>a very long item</div>
</div>
<div class="breadcrumb last" style="--border:2px;--gap:0px">
  <div>AA</div>
  <div>BB</div>
  <div>CC</div>
  <div>DD</div>
  <div>EE</div>
  <div>FF</div>
  <div>GG</div>
</div>

<div class="breadcrumb last" style="--gap:0px;--a:0px;">
  <div>Item 1</div>
  <div>Item 2</div>
  <div>Item 3</div>
  <div>Item 4</div>
</div>

<div class="breadcrumb" style="--dash:10,3;--border:1px;--gap:10px;--a:20px">
  <div>Item 1</div>
  <div>Item 2</div>
</div>

<div class="breadcrumb last" style="--dash:10,3;--border:2px">
  <div>Item 1</div>
  <div>Item 2</div>
  <div>Item 3</div>
</div>


<script>
if (CSS.paintWorklet) {              CSS.paintWorklet.addModule('/t_afif/pen/powNXwR.js');
} else {
  alert("Your browser cannot run this demo. Consider Chrome or Edge instead")
}
</script>
@property --border{
  syntax: '<length>';
  inherits: true;
  initial-value: 0;
}

.breadcrumb {
  display:flex;
  margin:10px 0;
  --border:3px;
  --a:10px; 
  --gap:5px; 
}
.breadcrumb > div {
  text-align:center;
  cursor:pointer;
  color:#00aaff;
  padding:10px calc(var(--a) + 10px);
  margin-left:calc(var(--gap) - var(--a) - var(--border)/2);
  --path:0 0,calc(100% - var(--a)) 0,100% 50%,calc(100% - var(--a)) 100%,0 100%,var(--a) 50%;
  position:relative;
  clip-path:polygon(var(--path));
  transition:.5s;
}
.breadcrumb > div:before {
  content:"";
  position:absolute;
  z-index:-1;
  inset:0;
  -webkit-mask:paint(polygon-border);
  background:CurrentColor;
}
.breadcrumb > div:hover {
  color:#ff00aa;
  z-index:1;
}
.breadcrumb > div:first-child {
  --path:0 0,calc(100% - var(--a)) 0,100% 50%,calc(100% - var(--a)) 100%,0 100%;
  padding-left:10px;
  margin-left:0;
}
.last > div:last-child {
  --path:0 0,100% 0,100% 100%,0 100%,var(--a) 50%;
  padding-right:10px;
}
body {
  background:#f2f2f2;
}
registerPaint('polygon-border', class  {

  static get inputProperties() {
    return [
      '--path',
      '--border',
      '--dash'
    ]
  }
  
  paint(ctx, size, properties) {

    const points = properties.get('--path').toString().split(',');
    const b = parseFloat(properties.get('--border').value);
    const d = properties.get('--dash').toString().split(',');
    const w = size.width;
    const h = size.height;
    
    const cc = function(x,y) {
      var fx=0,fy=0;
      if (x.indexOf('calc') > -1) {
        var tmp = x.replace('calc(','').replace(')','');
        if (tmp.indexOf('+') > -1) {
          tmp = tmp.split('+');
          fx = (parseFloat(tmp[0])/100)*w + parseFloat(tmp[1]);
        } else {
          tmp = tmp.split('-');
          fx = (parseFloat(tmp[0])/100)*w - parseFloat(tmp[1]);
        }
      } else if (x.indexOf('%') > -1) {
        fx = (parseFloat(x)/100)*w;
      } else if(x.indexOf('px') > -1) {
        fx = parseFloat(x);
      }
      
      if (y.indexOf('calc') > -1) {
        var tmp = y.replace('calc(','').replace(')','');
        if (tmp.indexOf('+') > -1) {
          tmp = tmp.split('+');
          fy = (parseFloat(tmp[0])/100)*h + parseFloat(tmp[1]);
        } else {
          tmp = tmp.split('-');
          fy = (parseFloat(tmp[0])/100)*h - parseFloat(tmp[1]);
        }
      } else if (y.indexOf('%') > -1) {
        fy = (parseFloat(y)/100)*h;
      } else if(y.indexOf('px') > -1) {
        fy = parseFloat(y);
      }
      return [fx,fy];
    }
    
    var p = points[0].trim().split(/(?!\(.*)\s(?![^(]*?\))/g);
    p = cc(p[0],p[1]);
    ctx.beginPath();
    ctx.setLineDash(d);
    ctx.moveTo(p[0],p[1]);
    
    for (var i = 1; i < points.length; i++) {
      p = points[i].trim().split(/(?!\(.*)\s(?![^(]*?\))/g);
      p = cc(p[0],p[1]);
      ctx.lineTo(p[0],p[1]);
    }
    ctx.closePath();
    ctx.lineWidth = 2*b;
    ctx.strokeStyle = '#000';
    ctx.stroke();
  }

})
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.