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

Float: Getting Elements on the Same Line (Codepen)

Having a bit of difficulty with a small part of my projects layout. On the codepen, there are two separate divs (.social and .logo) that are children of the parent div (logo-row).

The children have float: left applied. The problem is, the contents are not on the same line. The social Icons are a bit above the logo, and the hello box is on its own line entirely.

I created a mock up of what I am trying to achieve below: alt text

Here is the codepen. http://codepen.io/bluehabit/pen/dPKaXw

Thanks in advance.

2 Answers

Firstly you need to change your .social, .logo, .box { float: left; } to .logo { float: left; } .social { float: right; }. Then you give your box float.box {float:right}. Your .social ul li need to have list-style: none; display: inline-block; margin-left: 9px; float: right; Then set your social a .social { width: 50%; } and your done - it should look something like that: http://codepen.io/anon/pen/EaRMjJ

That sort of works, the problem I found is when the .box and .social are set to float right the elements are out of order and I can't seem to figure out how to prevent that.

If you look at the concept in the original post the text box is to the right of the social icons. In your example, it is to the left.

You can just switch them in your html or you can use flexbox order - http://www.reddit.com/r/css/comments/1v1gv7/change_order_of_divs_with_css/