我需要在包含@roll
的最后一个li:after
元素中应用background-color: #a1c642
动画。我该怎么办?
@-moz-keyframes roll {
0% { width:0; }
100% { width:100%; }
}
@-webkit-keyframes roll {
0% { width:0; }
100% { width:100%; }
}
.multi-steps > li.is-active:before, .multi-steps > li.is-active ~ li:before {
content: counter(stepNum);
font-family: inherit;
font-weight: 700;
}
.multi-steps > li.is-active:after, .multi-steps > li.is-active ~ li:after {
background-color: #ededed;
}
.multi-steps > li.is-active-acao-lojista:before, .multi-steps > li.is-active-acao-lojista ~ li:before {
content: counter(stepNum);
font-family: inherit;
font-weight: 700;
}
.multi-steps > li.is-active-acao-lojista:after, .multi-steps > li.is-active-acao-lojista ~ li:after {
background-color: #ededed;
}
.multi-steps {
display: table;
table-layout: fixed;
width: 100%;
}
.multi-steps > li {
counter-increment: stepNum;
text-align: center;
display: table-cell;
position: relative;
color: #a1c642;
z-index:99!important;
}
.multi-steps > li.is-active {
color: #a1c642!important;
}
.multi-steps > li.is-active-acao-lojista {
color: darkorange!important;
}
.multi-steps > li:before {
content: '\f00c';
content: '\2713;';
content: '\10003';
content: '\10004';
content: '\2713';
display: block;
margin: 0 auto 4px;
background-color: #fff;
width: 36px;
height: 36px;
line-height: 32px;
text-align: center;
font-weight: bold;
border-width: 2px;
border-style: solid;
border-color: #a1c642;
border-radius: 50%;
}
.multi-steps > li:after {
content: '';
height: 2px;
width: 100%;
background-color: #a1c642;
position: absolute;
top: 16px;
left: 50%;
z-index: -1;
}
.multi-steps > li:last-child:after {
display: none;
}
.multi-steps > li.is-active-acao-lojista:before {
background-color: #fff;
border-color: darkorange;
}
.multi-steps > li.is-active:before {
background-color: #fff;
border-color: #a1c642;;
}
.multi-steps > li.is-active ~ li {
color: #808080;
}
.multi-steps > li.is-active ~ li:before {
background-color: #ededed;
border-color: #ededed;
}
.multi-steps > li.is-active-acao-lojista ~ li {
color: #808080;
}
.multi-steps > li.is-active-acao-lojista ~ li:before {
background-color: #ededed;
border-color: #ededed;
}
<ul class="list-unstyled multi-steps">
<li>Pedido recebido</li>
<li class="is-active">Pagamento aprovado</li>
<li class="is-active-acao-lojista">Faturar pedido</li>
<li class="is-active-acao-lojista">Enviar dados rastreio</li>
<li>Confirmar entrega</li>
</ul>
我尝试类似的事情:
.multi-steps > li:after:last-child{
animation-name: roll;
animation-duration: 5s;
animation-timing-function: linear;
}
也尝试过:
.multi-steps > li::after:nth-last-child(2){
animation-name: roll;
animation-duration: 5s;
animation-timing-function: linear;
}
但是什么也没发生。
答案 0 :(得分:0)
只需尝试将“ li :: after:nth-last-child(2)”更改为“ li:nth-child(2):: after”。您写的是错误的。您不能同时选择最后一个孩子和第n个孩子。
请记住,子选择器应用于li本身。因此,它应该紧随其后。然后,您可以选择要样式化的li子内部的伪元素。