Dotted border from left to right (between two elements)

Issue

I have no idea how to do this one.

What I want to do is print dots between Uncategorized and 82,359, or at least the illusion, i guess i have to do something with a dotted border

<ul class="list">
    <li>
    <a href="#">
        <span class="count">82,359</span>
        Uncategorized
    </a>
    </li>
</ul>

The CSS

.list a {
display: block;
padding: 6px 10px;
}

.list .count {
font-weight: normal;
float: right;
color: #6b7a8c;
}

What I want is this:

what i want
What I’ve tried, and the only way i can think of is <div style="border-bottom: 1px dotted #CCC;"></div> between .count and Uncategorized, but that add the border on top of the two

Solution

Based on the example used here: Dot Leaders as referenced by Black Hat Samurai, slight change to the markup and the CSS from the link helped it.

Added comments to explain how the code works.

ul.list {
  max-width: 220px; /* Set the width for the whole list */
  list-style: none;
  padding: 0;
}
ul.list li:before {
  float: left; /* Let the before pseudo element start from the leftmost position of each list item */ 
  width: 0;
  white-space: nowrap; 
  content: ".....................................................";
  color: #ccc;
  font-weight: bold;
}
ul.list span:first-child {
  background: white; 
  padding-right: 0.2em;
}
ul.list span + span {
  float: right; /* Align the count to the rightmost position of the list */
  background: white;
  padding-left: 0.2em;
}
<ul class="list">
  <li>
    <a href="#">

      <span class="title">Uncategorized</span>
      <span class="count">82,359</span>

    </a>
  </li>
</ul>

Answered By – m4n0

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published