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

How to position

Hi. Ive been following the deep dive on CSS. and I am trying to design a website just to apply what I have learned. I am having trouble positioning one dive next to the other one. I tried with float but it did not work.

Here is a image http://imgur.com/u9mfzjl

The code is here

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

Go over to codepen to and create a working demo to show us your issue.

Don't know how to use it? No problem! :smile:

Here's a quick guide on how to use codepen

@Kevin - Rather than go through the extra step of saving a pen as a gist just share the link of the pen itself in the future. As the pen is an interactive demo and much more useful for troubleshooting than a the static text in a gist.

3 Answers

You didn't float any of your elements. Add this to you CSS .grid1, .grid2, .grid3, .grid4, .grid5 { float: left; }.

If you are fuzzy on how this works, I'd recommend you review the video here on Treehouse on floats

If after reviewing the video and working through the code challenge you are still confused then head over to learnlayout.com.

There's also a good explaination on floating elements in this tutorial on CSS positioning.

Ok. Thank you a lot. it fixed the problem although I don't know why. I guess I dont understand floats as I thought I did.

If you don't fully understand how floats works, my unsolicited advice is as follows ...

Being able to position elements on the page is most important part of CSS. I suggest read about CSS positioning and then you go through all of learnlayout.com.


I had my first ah-ha moment with CSS when I figured out how to do this using floats. No absolute positioning, that would be cheating. Piet Mondrian - Composition II in Red, Blue, and Yellow - 1930

Source: Piet Mondrian Composition II

Hello Kevin,

Do you have a wrapper for those two divs that are supposed to be side to side? It would be easier to help if we could see the exact code you tried. Care to show us?

Yeah here the code. no I dont have a wrapper.

https://gist.github.com/anonymous/7186077

you may have floated them both to the left which is ok, but as a div is a block element you will need to get them to display inline too - try that