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

Floating an element

How do I float an element to the left or right of the container box, so that as I scroll down the page on the viewport the elements also follow the scrolling up or down?

2 Answers

You could use negative margins. Or absolute positioning.

I think a better way though would be to have a parent container and have your current container inside, along with the other elements you want to display next to it, and then float both of those elements.

If you want and element to be outside of a container, you probably should reconsider having it in the container in the first place =]

Thank you. Than helped!

Do you mean like this ...

http://codepen.io/jamesbarnett/pen/JwFuy

Not sure what I was looking at. It seemed to be a box outside of a box but within the margins for a header. My floated elements with contact links (facebook, tweeter...) would be outside of the main container. I do not have an example but will send it if I see one. TY