Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS Enhancing Design with CSS Finishing Touches Applying Media Queries

karan karan
karan karan
Web Development Techdegree Student 4,139 Points

margin problem

How come we were not able to adjusts two elements on one Line and then we added 4% of margin too and still the other element did not fall down? we had to give -4px initially to manage both of them into one line and then we added 4% which is approx 25px and both the Elements manage to adjust?

1 Answer

Jason Larson
Jason Larson
7,490 Points

Note 2 things when the 4% is added. First, the size of the columns is changed from 50% to 48%. With 2 columns, this would leave 4% extra. The other thing to note is that when the 4% is originally added, you had the same problem where the second column fell down below the first. The pictures only display correctly when calc() is used to set the margin to calc(4% - 4px), which covers the extra pixels that were needed to keep the second column on the same line.