0

I would like to create a curved/flowing line with CSS, having circles on it with text associated with them. I tried to find it on here, searched Google and even asked ChatGPT but the idea seams to either be pretty unique or people who have figured it out haven't shared it (yet).

To give you a visual representation of what I am trying to achieve, here is a screenshot from the design:

enter image description here

I have tried creating a line using border-radius, but instead of giving me a curved line like in the design, it gave me a box with round edges:

/* Make sure to include the Font Awesome CSS */

@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css');
.timeline-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.timeline {
  position: relative;
  width: 100%;
  height: 50px;
  background-color: #ccc;
  border-top-left-radius: 50px;
  border-top-right-radius: 50px;
  border-bottom-right-radius: 50px;
  border-bottom-left-radius: 50px;
}

.circle {
  position: absolute;
  width: 10px;
  height: 10px;
  background-color: #fff;
  border-radius: 50%;
  text-align: center;
}

.circle i {
  font-size: 8px;
  color: #000;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.circle .text {
  display: none;
}

.circle:nth-of-type(1) {
  left: 25%;
}

.circle:nth-of-type(2) {
  left: 50%;
}

.circle:nth-of-type(3) {
  left: 75%;
}


/* Responsive styles */

@media (min-width: 768px) {
  .circle {
    width: 20px;
    height: 20px;
  }
  .circle i {
    font-size: 16px;
  }
  .circle .text {
    display: block;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translate(-50%, 0);
    width: 80%;
    text-align: center;
  }
}
<div class="timeline-container">
  <div class="timeline">
    <div class="circle">
      <i class="fas fa-check"></i>
      <div class="text">
        <h3>Heading 1</h3>
        <p>Text 1</p>
      </div>
    </div>
    <div class="circle">
      <i class="fas fa-check"></i>
      <div class="text">
        <h3>Heading 2</h3>
        <p>Text 2</p>
      </div>
    </div>
    <div class="circle">
      <i class="fas fa-check"></i>
      <div class="text">
        <h3>Heading 3</h3>
        <p>Text 3</p>
      </div>
    </div>
    <div class="circle">
      <i class="fas fa-check"></i>
      <div class="text">
        <h3>Heading 4</h3>
        <p>Text 4</p>
      </div>
    </div>
  </div>
</div>

I have some knowledge of both CSS3 as well as modern Javascript (ES6), but making such a line has had me scratching my head for over 3 days now. One catch of this is; it has to be responsive, preferably with the line curving 'over' itself and continuing in opposite direction, with space for the text.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Gidi
  • 1
  • 1
  • 2
    Before asking please read [ask] and [mcve] – Sfili_81 Jan 26 '23 at 10:07
  • And have a look at https://stackoverflow.com/questions/64678768/how-can-i-make-a-curve-line-to-join-two-node-in-html-and-css and start with connection 2 bubbles. And then the other two and so on. – Uwe Jan 26 '23 at 12:41
  • 1
    You should create it with SVG – vsync Jan 26 '23 at 13:05
  • Such designs are a big headache, especially for the average developer. It takes a highly skilled developer to pull such a thing off. You best option to go search online for a solution and copy it. – vsync Jan 26 '23 at 16:35
  • Similar code for inspiration: https://stackoverflow.com/a/67967512/104380 – vsync Jan 26 '23 at 16:43

0 Answers0