Вы можете использовать инверсию порядка элементов в HTML. Затем, используя order
, как в ответе Michael_B , вы можете использовать flex-direction: row-reverse;
или flex-direction: column-reverse;
в зависимости от вашего макета.
Рабочий пример:
.flex {
display: flex;
flex-direction: row-reverse;
/* Align content at the "reversed" end i.e. beginning */
justify-content: flex-end;
}
/* On hover target its "previous" elements */
.flex-item:hover ~ .flex-item {
background-color: lime;
}
/* styles just for demo */
.flex-item {
background-color: orange;
color: white;
padding: 20px;
font-size: 3rem;
border-radius: 50%;
}
5
4
3
2
1