Reputation: 63
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'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
Upvotes: 4
Views: 5415
Reputation: 879
With flex it's really easy now :
<div class="parent">
<span class="description">Description</span>
<div class="dottedDiv"></div>
<span class="price">price</span>
</div>
CSS :
.parent {
display: flex;
justify-content: center;
}
.description{
padding-right: 1rem;
}
.price{
padding-left: 1rem;
}
.dottedDiv{
height : 1.6rem;
border-bottom: 1px dotted black;
flex-grow: 2;
}
Note that I'm reducing the height of the dotted div, to have the line exactly where I want it to be.
Upvotes: 2
Reputation: 114990
I'd go with something like this
.list {
min-width:15em;
}
.first {
float:left;
margin-right:0.5em;
color:#2B91AF
}
.price {
float:right;
margin-left:0.5em;
width:4em;
text-align: right;
}
.list:after {
content:'';
border-bottom:dotted 2px tomato;
display:block;
overflow:hidden;
height:0.8em;
}
<p class="list">
<i class='first'>Co-Pay:</i>
<i class="price">$150.00</i>
</p>
<p class="list">
<i class='first'>Pay:</i>
<i class="price"> $5.00</i>
</p>
<p class="list">
<i class='first'>Co-Pay: item</i>
<i class="price"> $15.00</i>
</p>
<p class="list">
<i class='first'>Co-Pay: great deal</i>
<i class="price"> $1.00</i>
</p>
Upvotes: 2
Reputation: 32255
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>
Upvotes: 3
Reputation: 1502
Try this..
HTML
<ul class="list">
<li>
<a href="#">
<span>Uncategorized</span>
<span class="count">82,359</span>
</a>
</li>
</ul>
CSS
ul{
list-style-type: none;
font-family: arial;
font-size: 17px;
}
a{
text-decoration: none;
color: #000;
}
ul.list li{
}
li span + span:before{
content: "..................................";
white-space: nowrap;
}
Check out this Fiddle
Upvotes: 0
Reputation: 412
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.list a {
display: block;
border-bottom: dotted 1px;
height: 13px;
}
.list .title {
padding-right: 5px;
background-color: white;
font-weight: normal;
float: left;
color: #6b7a8c;
}
.list .count {
background-color: white;
padding-left: 5px;
font-weight: normal;
float: right;
color: #6b7a8c;
}
</style>
</head>
<body>
<ul class="list">
<a href="#">
<span class="title">Uncategorized</span>
<span class="count">82,359</span>
</a>
</ul>
</body>
</html>
I used a dirty hack. First of all, tag now has a height 13. Then I added background-color: white (or whatever) to remove dots under the text. Please be careful of using this solution!
Upvotes: 0
Reputation: 23483
What you are looking for is called Dot Leaders. Here is an article that describes how you achieve the desire effect:
http://www.w3.org/Style/Examples/007/leaders.en.html
Upvotes: 1