Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Cosimo Scarpa
Cosimo Scarpa
14,047 Points

Add a variable inside the @Mixin based on the number of the child.

Hi there,

I'm trying to animate 4 circles with a transition, from left to right, using Sass. So, now I want to give a different distance, like an extra 5px time the number of the element.

I'm very close (I think) but I have an issue to add that extra distance for each of them.

<div class="circle slide"></div>
<div class="circle slide"></div>
<div class="circle slide"></div>
<div class="circle slide"></div>
@mixin keyframes($animation-name, $axis, $start, $end) {
    @keyframes #{$animation-name} {
        0% {
            transform: unquote("#{$axis}(#{$start})");
        }

        50% {
            transform: unquote("#{$axis}(#{$end})");
        }

        100% {
            transform: unquote("#{$axis}(#{$start})");
        }
    }
}

@include keyframes(slide, translateX, 0, 300px);

.slide {
  animation: slide 2s ease .1s infinite;
}

.circle {
  opacity: 1;
  height: 50px;
  width: 50px;
  background: indianred;
  margin: 5px;
  border-radius: 50%;
}

I hope I was clear.

Thank you in advance (: