Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

Abe Layee
Abe Layee
8,378 Points

Animation won't center on the page.

Hello there. I ran into a little bug and I have been trying to figure it out where I went wrong. However, I can't find my mistake in my code. My animation supposed to be in the center of the page. Here is my codepen link http://codepen.io/Layee/pen/qdmjvy

3 Answers

Basya Rosemann
Basya Rosemann
1,974 Points

Hi Abe,

I think your problem is that you are absolutely positioning the h2 with class "removeMargin", and giving the value "left: 50%".

What is happening is that your h1 and h2 block's top left corner (and not the center of your h1/h2 block) is being positioned at the 50% point.

Abe Layee
Abe Layee
8,378 Points

So how do I fix it?

Basya Rosemann
Basya Rosemann
1,974 Points

You can give it a different value, such as "left: 35%;", instead of "left:50%".

Personally I would not absolutely position these elements at all. One reason for that is that it won't necessarily be centered on different width screens. You can find ways of centering elements on your page in this very simple article: https://css-tricks.com/centering-css-complete-guide/

Good luck!