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 trialznzlcrstkk
Front End Web Development Techdegree Graduate 28,511 PointsFinally, create a rule that targets an h1. Use the px-to-rem function to convert a font-size value of 60px to a value in
Finally, create a rule that targets an h1. Use the px-to-rem function to convert a font-size value of 60px to a value in rem units.
$base-font-size: 16px;
// Write your function here
@function px-to-rem ($target, $context:$base-font-size) {
@return ($target / $context) * 1rem;
}
h1 {
font-size:px-to-rem (60px, rem);
}
5 Answers
bill curry
Front End Web Development Techdegree Student 7,841 PointsActually, Jeanne (above is correct). You don't need that rem parameter in the function because you're already multiplying by 1rem to get rem units. Here is the solution in an easy to read format.
$base-font-size: 16px;
// Write your function here
@function px-to-rem($target, $context: $base-font-size) {
@return ($target / $context) * 1rem;
}
h1 {
font-size: px-to-rem(60px);
}```
Note that there is no space between "px-to-rem" and the parentheses. The engine will reject this:
```h1 {
font-size: px-to-rem (60px);
}```
Jeanne Bachmann
765 Points$base-font-size: 16px;
// Write your function here @function px-to-rem ($target, $context: $base-font-size) { @return ($target / $context) * 1rem; }
h1 { font-size: px-to-rem(60px); }
You just have to write "(60px)" and you must delete space between "px-to-rem" and "(60px);" Hope it's the right way :)
znzlcrstkk
Front End Web Development Techdegree Graduate 28,511 PointsI think that i'm close, but dont know exactly what to do
Levi Donaldson
7,692 Points// I think this is what you're looking for
h1 { font-size: px-to-rem(60px, 1rem); }
// The rem unit needs a value so just writing (60px, rem) like above doesn't give it the proper calculation. This should help though.
Mike Siwik
Front End Web Development Techdegree Student 14,814 Pointsh1 { font-size: px-to-rem(60px); }```
is the correct answer, minus the three back ticks...
Hagop Almadjian
Front End Web Development Techdegree Student 7,051 Pointshow is 60/16 =60 can someone explain
Sekoyya Little
Front End Web Development Techdegree Student 7,651 PointsSekoyya Little
Front End Web Development Techdegree Student 7,651 PointsTHIS GUY HAS THE RIGHT ANSWER ^