I have been searching for a solution for this both here, and on google with no success.
I want to create a Vertical line which has dots in the ends and a few along the line.
img for example:
how can I achieve this with css ? I can do a dotted line with spacing, but I have no idea how to create the line also, and if that is even possible ?
What is a vertical line? A vertical line is a line extending up and down. On a table (like the one shown to the right), the legs of the table are vertical lines. The y-axis is an example of a vertical line.
You can use <hr> , as it is semantically correct, and then use CSS to convert it to a vertical line.
Its simple to add a horizontal line in your markup, just add: <hr>. Browsers draw a line across the entire width of the container, which can be the entire body or a child element.
Here's a quick snippet that might help you with your problem:
.bar {
list-style: none;
}
.bar >li {
position: relative;
}
.bar>li:before {
content: '\25CF';
margin-right: 10px;
font-size: 20px;
}
.bar>li:after {
position: absolute;
left: 0;
top: 0;
content: '';
border-left: 2px solid black;
margin-left: 5px;
height: 100%;
}
.bar >li:first-of-type:after {
top: 50%;
}
.bar >li:last-of-type:after {
top: -50%;
}
<ul class="bar">
<li>element 1</li>
<li>element 2</li>
<li>element 3</li>
<li>element 4</li>
<li>element 5</li>
</ul>
The idea is that you use a list and each element's bullet is replaced with a :before
symbol of a Unicode black circle, while each :after
selector for the elements contains the element's share of the vertical line. The first and last list elements have an extra rule to truncate their border-line, so that it does not go past the black circle.
Tweak it a bit to get the exact effect you want!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With