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

General Discussion

Maria Cuan
Maria Cuan
4,500 Points

rocking animation

Hello everyone, thank you for your help in everything :) I once again must ask your advice on a css animation. I can't find the reason why my boat is not rocking back and forth.

.rocking { -webkit-animation-name: Rocking; -webkit-animation-duration: 3s; -webkit-animation-iteration-count: infinite; -webkit-animation-timing-function: ease-in-out; -moz-animation-name: Rocking; -moz-animation-duration: 3s; -moz-animation-iteration-count: infinite; -moz-animation-timing-function: ease-in-out; }

@webkit-keyframes Rocking{ from { -webkit-transform: rotate(0deg); } 70% { -webkit-transform: rotate(-5deg); } to { -webkit-transform: rotate(0deg); } }

My html is basically:

<object type="image/svg+xml" data="img/boat-01.svg" class="boat floating rocking">
        <!-- fallback image in CSS -->
        </object>

11 Answers

Alex Lasek
Alex Lasek
11,536 Points

to play the animation backward and forward you should add and set up animation-direction:alternate-reverse if it needs to go forth and then back the value will be just alternate

cheers

Maria Cuan
Maria Cuan
4,500 Points

Well I was looking for my boat to rotate a little (-5deg) and its not doing it :(

Alex Lasek
Alex Lasek
11,536 Points

there are 2 things you can do so simulate boat moving back and forth. One is rotate it -5 deg and then +5deg, but it wouldn't be smooth. @-webkit-keyframes Rocking /* Safari and Chrome */ { from { -webkit-transform: rotate(0deg); } 33% { -webkit-transform: rotate(-5deg); } 66% { -webkit-transform: rotate(0deg); } to {-webkit-transform: rotate(5deg); } }

Except for that they added move on Y (translateY(-10px)) that's why the animation looks like the boat moving back and forth

@-webkit-keyframes Rocking /* Safari and Chrome */ { 50% { -webkit-transform: rotate(-5deg) translateY(-10px); }

hope that helps,

cheers

Maria Cuan
Maria Cuan
4,500 Points

Oh wow, thanks :) Any idea on why my scrollbar is gone? o_o

http://codepen.io/esthercuan/pen/Hpdqv

Alex Lasek
Alex Lasek
11,536 Points

hmm scrollbar? where should it be?

Maria Cuan
Maria Cuan
4,500 Points

when you resize my page to a smaller resolution, all my elements stack. But you cannot scroll downwards to see the bottom ones. Is it because my background is fixed?

Alex Lasek
Alex Lasek
11,536 Points

this is what I see after resize the browser https://dl.dropboxusercontent.com/u/83685159/small.png

and honestly speaking, I have no idea, what scrollbar you are talking about :)

Maria Cuan
Maria Cuan
4,500 Points

If you just push your window up so you overlay content, there is no way to scroll around to see it. :(

Alex Lasek
Alex Lasek
11,536 Points

ohh, you mean in on codepen. It's because of the styling the window. The body of your page is default set up to overlay:hidden;

http://codepen.io/anon/pen/apCnD

hope, I got your point :)

Maria Cuan
Maria Cuan
4,500 Points

Oh I can scroll now! But not in my index.html Let me show you a screenshot. Thank you for your patience :)

https://www.dropbox.com/s/rptlcg76m4hjes7/Esther_Cuan_Design___Web.jpg

Alex Lasek
Alex Lasek
11,536 Points

LOL, sorry I had no idea, that you are talking about the navigation button ;/

Anyway, it won't work on codepen, as it is right now. To load the page properly all your links have to be absolute, uploaded somewhere on the Internet.

that's why any js action or external css styling won't be executed or applied.

cheers

Maria Cuan
Maria Cuan
4,500 Points

Thank you so much for all your help and patience! Alex