Skip to main content
CSS Tip

Dynamic Node Connection (CSS-only Diagram) II

Extending the previous implementation to add more connection types. This time, the connectors will stick to the specified sides, regardless of the node's position. Another cool demo made possible with anchor positioning, border-shape, shape(), container queries, if(), and more!

CSS-only diagram

Drag the nodes in the demo below and see the magic in play!

⚠️ Chromium-only for now ⚠️

See the Pen CSS-only diagram with dynamic connections II by Temani Afif (@t_afif) on CodePen.

I used three types of connections.

A left-to-right connection:

See the Pen left-to-right connection by Temani Afif (@t_afif) on CodePen.

A left-to-left connection:

See the Pen Left-to-left connection by Temani Afif (@t_afif) on CodePen.

A right-to-right connection:

See the Pen right-to-right connection by Temani Afif (@t_afif) on CodePen.

The possibilities are endless. Stay tuned for more CSS-only diagrams!


More CSS Tips