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 trialJeffrey Munn
9,520 PointsWhy not position columns absolutely?
I have a hunch why this might be, but wanted to get others' opinion. Guil mentions that typically, absolute positioning would not be used to create columns. Why not?
The only reason I can come up with is that it is more difficult to make changes. Other than that... I'm not sure.
3 Answers
Paul Mather
3,313 PointsPositioning a column with absolute
really has no benefit and causes more issues than it's worth in different situations. You should only ever absolutely position an element if it's needed, for example if you want to position an element within another div without having to change the markup of your HTML. Using position absolute can have many benefits, but learning how and when to use it is a learning curve.
When making changes to your code at a later date, you may find many unwated problems as a result, especially since you're taking the absolutely positioned div out of the flow of the document.
An example of when i may use position: absolute;
is when i want to position a ribbon that says, let's say for the sake of the example "Featured" and i want it to appear in the top right side of a div, but has to sit slightly outside of the div in order to have the effect of it wrapping around the div - i.e. look at this example; http://jsfiddle.net/chriscoyier/H6rQ6/1/
Generally you would create an image for a ribbon like this since it is a much more cross-browser compatible method.
Jeffrey Munn
9,520 PointsI had considered that as well, but it seemed that when Guil did it using percentage offsets rather than exact pixels, it adjusted fine.
Derek Etnyre
20,822 PointsIf the size of the browser window changes, the positioning of the columns would not adjust along with it.
Jeffrey Munn
9,520 PointsJeffrey Munn
9,520 PointsThank you!