<ol class="cp_clist">
<li>css</li>
<li>html</li>
<li>copy</li>
<li>easy</li>
</ol>
ol.cp_clist {
padding: 0;
counter-reset:cp_clist; /*数字をリセット*/
list-style-type: none;
}
ol.cp_clist li {
position: relative;
display: flex;
align-items: center;
margin: 10px;
padding: 0 10px 0 40px;
min-height: 30px;
border: 1px dotted #f1c6c6;
transition: 0.3s;
}
ol.cp_clist li:nth-child(4n+2){
border-color:#8cd9bc;
}
ol.cp_clist li:nth-child(4n+3){
border-color:#9575CD;
}
ol.cp_clist li:nth-child(4n+4){
border-color:#f8e5ab;
}
ol.cp_clist li:before {
position: absolute;
left: 0;
display: flex;
justify-content: center;
align-items: center;
/* カウントさせる */
counter-increment: cp_clist;
content: counter(cp_clist);
/*装飾*/
color: #fff;
width: 30px;
height: 30px;
}
ol.cp_clist li:nth-child(4n+1):before{
background: #F06292;
}
ol.cp_clist li:nth-child(4n+2):before{
background: #4DB6AC;
}
ol.cp_clist li:nth-child(4n+3):before{
background: #9575CD;
}
ol.cp_clist li:nth-child(4n+4):before{
background: #FFB74D;
}
/*hover時の設定*/
ol.cp_clist li:hover {
color:#fff;
}
ol.cp_clist li:nth-child(4n+1):hover{
background: #F06292;
}
ol.cp_clist li:nth-child(4n+1):hover:before{
background: #fff;
color: #F06292;
}
ol.cp_clist li:nth-child(4n+2):hover{
background: #4DB6AC;
}
ol.cp_clist li:nth-child(4n+2):hover:before{
background: #fff;
color: #4DB6AC;
}
ol.cp_clist li:nth-child(4n+3):hover{
background: #9575CD;
}
ol.cp_clist li:nth-child(4n+3):hover:before{
background: #fff;
color: #9575CD;
}
ol.cp_clist li:nth-child(4n+4):hover{
background: #FFB74D;
}
ol.cp_clist li:nth-child(4n+4):hover:before{
background: #fff;
color: #FFB74D;
}