Can anyone think of a way to use the numbers in an ol
/li
list to label images?
<ol>
<li><img /></li>
<li><img /></li>
<li><img /></li>
</ol>
With some CSS applied should output the following:
------ ------ ------
| | | | | |
| | | | | |
| 1| | 2| | 3|
------ ------ ------
Where each square is a small profile picture.
I know I can insert a new element in the li
with a numeral in it and manipulate that as needed, but I'd like to do it with the inbuilt ol
numbering.
Easy enough:
ol {
counter-reset: listCount;
}
li {
float: left;
border: 3px solid #f90;
counter-increment: listCount;
position: relative;
}
li:after {
content: counter(listCount,decimal-leading-zero);
position: absolute;
bottom: 0;
right: 0;
width: 2em;
height: 2em;
color: #fff;
background-color: rgba(0,0,0,0.5);
text-align: center;
line-height: 2em;
}
JS Fiddle demo.
This does, of course, require the user to have a browser with the capacity for using css-generated-content, which pretty rules out IE.
References:
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