Skip to main content
CSS Tip

Bending a Straight Line using Modern CSS

Updating the previous implementation with another idea of connection. This time, it's a straight line that adjusts based on the distance between the two circles. It bends when they get closer and stretches (becomes thinner) when they get farther. Implementing physics using pure CSS!

Another demo powered by modern CSS (Anchor Positioning, border-shape, if(), and more).

CSS-only connected circles with curved line

Drag the circles and see the magic in play!

⚠️ Chrome-only for now ⚠️

See the Pen Bending a straight line using pure CSS by Temani Afif (@t_afif) on CodePen.

You can have as many elements as you want and adjust the connection setting (line length and number of curves)

See the Pen Bending a straight line using pure CSS II by Temani Afif (@t_afif) on CodePen.


More CSS Tips