Skip to content

Instantly share code, notes, and snippets.

@cemre
Created April 1, 2013 19:21
Show Gist options
  • Save cemre/5287043 to your computer and use it in GitHub Desktop.
Save cemre/5287043 to your computer and use it in GitHub Desktop.
Rails to_sentence in pure CSS
<span class="join-as-sentence">
<span class="item">
David Yen
</span>
<span class="item">
Hursh
</span>
<span class="item ">
Josh
</span>
<span class="item">
Cemre
</span>
</span>
.join-as-sentence {
.item:after {
content: ', ';
margin-left: -4px;
}
.item:nth-last-child(2):after {
margin-left: 0;
margin-right: 0;
content: ' and ';
}
.item:last-child:after {
content: '';
margin-left: 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment