DEV Community

Cover image for How to make linked bullet point with css
Abhi Raj
Abhi Raj

Posted on

How to make linked bullet point with css

here is the basic idea

you make three li list under ul or li tag

        <ul>
          <li>item 1</li>
          <li>item 2</li>
          <li>item 3</li>
        </ul>
Enter fullscreen mode Exit fullscreen mode

you make the li tag position: relative; and give some left padding

li {
  height: 40px;
  padding-left: 20px;
  display: flex;
  align-items: center;
  position: relative;
}
Enter fullscreen mode Exit fullscreen mode

you use li::before css property and make left border around.

li::before {
  content: '';
  position: absolute;
  left: -16px;
  border-left: 2px solid black;
  height: 100%;
  width: 1px;
}
Enter fullscreen mode Exit fullscreen mode

Image description

Now you use li::after css property and make three circles around it

li::after {
  content: '';
  display: inline-block;
  height: 10px;
  width: 10px;
  border-radius: 50%;
  background-color: blue;
  margin-left: -80px;
}

Enter fullscreen mode Exit fullscreen mode

Image description

Now finally you crop the line from first and last list


li:first-child:before {
  top: 20px;
}

li:last-child:before {
  top: -20px;
}
Enter fullscreen mode Exit fullscreen mode

and result:

Image description

full code:

html:

  <ul>
          <li>item 1</li>
          <li>item 2</li>
          <li>item 3</li>
        </ul>
Enter fullscreen mode Exit fullscreen mode

css:

li {
  height: 40px;
  padding-left: 20px;
  display: flex;
  align-items: center;
  position: relative;
}

li::before {
  content: '';
  position: absolute;
  left: -16px;
  border-left: 2px solid black;
  height: 100%;
  width: 1px;
}

li::after {
  content: '';
  display: inline-block;
  height: 10px;
  width: 10px;
  border-radius: 50%;
  background-color: blue;
  margin-left: -80px;
}


li:first-child:before {
  top: 20px;
}

li:last-child:before {
  top: -20px;
}

Enter fullscreen mode Exit fullscreen mode

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay