V
V
VegasChickiChicki2019-02-03 19:38:50
Sass
VegasChickiChicki, 2019-02-03 19:38:50

Is it possible to somehow replace this expression?

&:nth-child(1)
    left: 50%
    margin-left: -450px
  &:nth-child(2)
    left: 200%
    margin-left: -450px
  &:nth-child(3)
    left: 350%
    margin-left: -450px
  &:nth-child(4)
    left: 500%
    margin-left: -450px
  &:nth-child(5)
    left: 650%
    margin-left: -450px
  &:nth-child(6)
    left: 800%
    margin-left: -450px

Is it possible to write any formula in SASS, in which I specify n-elements, and she writes n-:nth-child's to me, adding 150% to each next in the left parameter, and leaving the margin-left: -450px parameter static ?
ps I heard about formulas in SASS, but I'm not familiar with them, is it possible to implement this?
pps It would also be great to see this, if possible, in JS.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-02-03
@VegasChickiChicki

.item
  margin-left: -450px
  @for $i from 1 through 6
    &:nth-child(#{$i})
      left: $i * 150% - 100%

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question