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

Jeremy Coleman
Jeremy Coleman
5,449 Points

CSS Animation question..

I am starting to work with keyframes in CSS and I am trying to figure out how to make this work.

This is my current code.

@keyframes backgroundScroll {
    from {background-position: center;}
    to {background-position: 0 0;}
}

But would like to make the values random so the background scrolls randomly every time the website is refreshed. I would like to achieve this through CSS if possible.

Lucas Santos
Lucas Santos
19,315 Points

You will not be able to generate a random number with just CSS. You would either have to do it with SASS, Javascript or PHP. And if you would like this whenever the website is refreshed then you would have to use Javascript or PHP for the "refreshed" function.

Jeremy Coleman
Jeremy Coleman
5,449 Points

Okay thank you! I did a bit of research and that's all I could really find. Guess that explains why.