If you want to increase the counter of the listing we can do that easily with the help of counter increment using CSS.
This can be used like an variable in javascript and you just have to increment the value of the variable using CSS rules and it will track that how many times it is been used.
The following are the CSS properties that can be used to make CSS counter:
- counter-reset - It is used to creates or resets a counter.
- counter-increment - It is used to increment the counter value.
- content - It is used to insert the generated content.
- counter() or counters() function - It is used to add the values of a counter to an element.
Now let us take an example of how it works:
HTML:
<div class="OuterBox">
<div class="itemInside">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ut labore et dolore magna aliqua</div>
<div class="itemInside">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ut labore et dolore magna aliqua</div>
<div class="itemInside">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ut labore et dolore magna aliqua</div>
<div class="itemInside">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ut labore et dolore magna aliqua</div>
<div class="itemInside">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ut labore et dolore magna aliqua</div>
<div class="itemInside">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ut labore et dolore magna aliqua</div>
<div class="itemInside">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ut labore et dolore magna aliqua</div>
<div class="itemInside">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ut labore et dolore magna aliqua</div>
<div class="itemInside">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod ut labore et dolore magna aliqua</div>
</div>
STYLE/CSS:
.OuterBox {
counter-reset: aaaaa;
width: 400px;
font: 12px/18px Verdana, Tahoma, sans-serif;
margin-bottom: 25px;
}
.itemInside { padding: 5px; }
.itemInside:before {
counter-increment: aaaaa;
content: counter(aaaaa);
margin: 0px -5px 0 5px;
padding: 1px 5px 0;
padding-right: 10px;
float: left;
padding-left: 10px;
color: white;
background-color: #369;
margin-right: 10px;
}
With the above code you can make the counter increment in CSS or you can also download the attached file.
Hope this will help you.
0 Comment(s)