есть ли способ использовать n n-го типа для вычисления какого-либо стиля?
Я делаю слайдер фотографий, и часть CSS в настоящее время выглядит так:
.container *:nth-of-type(1) img{
object-position: 0%;
}
.container *:nth-of-type(2) img{
object-position: calc(100% / 9 * 1);
}
.container *:nth-of-type(3) img{
object-position: calc(100% / 9 * 2);
}
.container *:nth-of-type(4) img{
object-position: calc(100% / 9 * 3);
}
.container *:nth-of-type(5) img{
object-position: calc(100% / 9 * 4);
}
.container *:nth-of-type(6) img{
object-position: calc(100% / 9 * 5);
}
.container *:nth-of-type(7) img{
object-position: calc(100% / 9 * 6);
}
.container *:nth-of-type(8) img{
object-position: calc(100% / 9 * 7);
}
.container *:nth-of-type(9) img{
object-position: calc(100% / 9 * 8);
}
.container *:nth-of-type(10) img{
object-position: 100%;
}
это легко сгенерировать с помощью js, но я бы хотел решение только для css. Это возможно?
codepen