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

CSS Positioning

Hi all,

I'm reading a book about positioning elements, and it mentions that you can create absolute position in the following manner () position: absolute: top: 100px; right: 200px; width: 280px; ()

I wanted to find out if you could create a responsive layout by using relative measurements instead of absolute ones. For example, would the following code work? () position: relative; top: 50%; right: 50%; width: 80%; ()

Thanks!

3 Answers

You can definitely use absolute positioning for responsive layouts. With the code you've provided, I find it weird you have a width: 80% declaration but right: 50% defined.

That seems like overflow will occur, and it will: I've given you a pen to see the likely undesirable effect of the code you've provided on SassMeister.

This is probably what you don't want to happen.

Yes, that would technically work. How well it would work would depend on the elements around it.

Thanks all!