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

Div block next to fixed div

How am I able to do this? Just like treehouse or youtube.

1 Answer

Tom Bedford
Tom Bedford
15,645 Points

Hi Mark

You can add a fixed position to the sidebar, then add a margin to the content equal to the width of the sidebar.

Have a look at this demo.

There are multiple ways to do this, including floats etc. What is a neat way to do this?

Tom Bedford
Tom Bedford
15,645 Points

You can't float against a fixed element so you'd have to float against the opposite side. I think the demo I made for you is a pretty neat way of doing it.

Tom Bedford
Tom Bedford
15,645 Points

Well, you could float to the same side, but you'd still need the margin to offset it same correct distance from the fixed element.