Desired Design:
- Create a dotted border on top of each
li
-element - Adjust the size of the dots and spacing between them using CSS or image/SVG manipulation
- Make the width of the
ul
responsive for varying border widths - Ensure that dots are not partially displayed when resizing the viewport, only full circles should be visible
In Brief: I want to avoid this issue (visible in the last dot?) while resizing the window:
https://i.sstatic.net/Esozt.jpg
I have ruled out these methods for achieving this effect:
- Using a tiled background image
- Utilizing an enormous background graphic
- Implementing
border-image
Solution Attempt:
I discovered a solution, although it requires tedious work. It functions by utilizing numerous unnecessary span
elements since the maximum element width is unknown.
The concept is simple: Dots that don't fit float into the hidden overflow.
Source
HTML
<ul>
<li>
<div>
<span></span><span></span><span></span><span></span><span></span><span></span>
</div>
Item 1
</li>
<li>
<div>
<span></span><span></span><span></span><span></span><span></span><span></span>
</div>
Item 2
</li>
</ul>
CSS
ul {
margin: 0;
padding: 0;
list-style: none;
line-height: 60px;
}
ul > li div {
overflow: hidden;
height: 2px;
}
ul > li div span {
float: left;
width: 2px;
height: 2px;
margin: 0 4px 0 0;
background: grey;
}
JSFiddle
Is there an elegant approach to address this, perhaps through inventive SVG or gradient techniques?