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 trialBrenda Krafft
18,036 PointsLong percentages in adaptive Media Queries
OK, I get that you want to be as detailed as possible with this, but how do you come up with these long percentage values? What's the math behind that?
2 Answers
Jacob Miller
12,466 PointsTarget รท Context = Result. So for example, if you wanted to convert a margin of 21px into a percentage. Lets say the margin is on a div inside the body element which has a max-width of 960px. So the math would be: 21 รท 960 = 0.021875. Then you convert that into a percentage by moving the decimal point two places to the right. So your percentage would be 2.1875%. Some combinations of target and context will produce those really long decimals that you see in the code challenge.
Brenda Krafft
18,036 PointsExcellent! Thank you; that makes total sense now.