r/csshelp • • Nov 12 '15

Help with adding a simple animation to a banner

Hello, I am currently working on making the subreddit r/abzugame. There are only a couple of things left I'd like to do that I am not familiar with. First, I'd like to add an effect similar to what you can see here on the game's official website, www.abzugame.com. There are little white specs rising in the center of the image. What would be the best way to go about achieving this effect? Any tips or links would be very helpful. The only other effect I'd like to do is have my pagename and header images enlarge slightly when you hover over them. Any help with either of these tricks would be much appreciated. Thanks!

6 Upvotes

5 comments sorted by

5

u/MatthewMob Nov 12 '15 edited Nov 12 '15

Just to say. This was a bitch to set up...

First thing you're going to want to do is download this image, and upload it to your stylesheet, naming it particles.

Then you're going to want to replace this code in your stylesheet:

#header {
  position:relative;
  height: 250px;
  background: url(%%bannersmallr%%) no-repeat;
  background-color: #343237;
  background-size: cover;
  border: none;
  text-align: center;
  background-position: center top;
}

with this code:

#header {
  position: relative;
  height: 250px;
  background: url(%%particles%%), url(%%bannersmallr%%);
  background-repeat: no-repeat, repeat-y;
  background-color: #343237;
  background-size: 350px 500px, cover;
  border: none;
  text-align: center;
  background-position: 30% 0px, center top;
  -webkit-animation: particles 14s linear infinite;
          animation: particles 14s linear infinite;
}
@-webkit-keyframes particles {
  from {
      background-position: 50% 0px, center top;
  }
  to {
      background-position: 50% -250px, center top;
  }
}
@keyframes particles {
  from {
      background-position: 50% 0px, center top;
  }
  to {
      background-position: 50% -250px, center top;
  }
}

and then it should be working. You can see a demo of this here (which was also a bitch to copy everything across to that sub).

Hope you enjoy! That's an hour of my life gone, haha

NINJA EDIT: You can also make the subreddit image that says /r/abzugame expand when hovered on using this code:

#header .redditname a:hover {
  transition: background-size 0.4s ease;
  background-size: 275px auto;
}

EDIT: My first gold! Glad it could be about helping someone, thank you so much :D

2

u/Nanaki-is-Nanaki Nov 12 '15

My hero... I've been trying to wrap my head around animation and keyframes for hours and was just about to call it a night and work on it tomorrow. I can't wait to see how you've achieved this because, wow, that looks absolutely amazing. I had created a png file with random specks trying to figure out how the heck to make it scroll up. An hour of your life just saved me days, so thank you!!!

2

u/Nanaki-is-Nanaki Nov 12 '15 edited Nov 12 '15

Do you think it is possible to make the scrolling infinite? I'm trying to get rid of the bump when the image replays

nvm i got it, just set the position from 0 to -500px and it looks good now. Wow, this looks so amazing

2

u/MatthewMob Nov 12 '15

Glad you like it, man

Thanks so much for the gold; made my day! :)

2

u/evanvolm Nov 12 '15

Good shit.