Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Blog preview card - mobile first

@KlaudiaK0205

Desktop design screenshot for the Blog preview card coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


What challenges did you encounter, and how did you overcome them?

The problem was adjusting the image size. I didn't know the terms fill & hug in Figma

Community feedback

P

@Bamo-D-Abdallah

Posted

It is perfect, but try to avoid using px, instead use rem, em, %, vw, and vh.

0

@arjumand07

Posted

@Bamo-D-Abdallah How do you figure out the required value for em, rem (relative units), do you just do hit and trial (like me) or is there a pattern/trick to do so?

0
P

@Bamo-D-Abdallah

Posted

@arjumand07 You can use a calculator to divide the px by 16, so to convert 360px to rem you divide 360/16 because 1 rem is 16px by default.

If you are using a preprocessor you can setup a function to do that:

// file name: _functions.scss
@use "sass:math";

@function toRem($px) {
  @if math.is-unitless($px) {
    @return math.div($px, 16) + rem;
  } @else {
    @error "Don't pass 'px' unit with the number";
  }
}


@function toEm($px) {
  @if math.is-unitless($px) {
    @return math.div($px, 16) + em;
  } @else {
    @error "Don't pass 'px' unit with the number";
  }
}

Now you can pass the pixel to the function and it will convert it:

@use "functions" as f

p {
  font-size: f.toRem(26);   //converts 26px to rem
}
1

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord