Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 1 year ago

Mobile First Approach using Flex and relative units.

weixin•110
@twx0504
A solution to the Blog preview card challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


  1. What did you find difficult while building the project? As a beginner, I found styling with CSS to be particularly challenging, especially when certain styles did not render as expected. For instance, achieving horizontal or vertical centering of elements proved difficult, leading me to experiment with various solutions found on platforms like YouTube.Working on responsive design poses a challenge when resizing the screen using dev tools, as maintaining the design's integrity becomes difficult. It tends to deform and look ugly.
  2. I am uncertain about specifying width and height in my project. I struggle with deciding when to set them and which units to use—whether in pixels, rems, percentages, or viewport units. In some instances, modifying these properties produced the desired changes, while in others, it didn't. How can I navigate these issues effectively? Additionally, I've encountered issues with overflowing content when the screen size becomes smaller. Both images and text tend to extend beyond the container boundaries. To address this, I've been using overflow: hidden or overflow: scroll. However, I'm uncertain whether this is a recommended solution or if there are better practices for handling such overflow concerns.
  3. I would like to know if it is advisable to split CSS code into different .css files. Sometimes, the code becomes extremely long and challenging to locate. Is this a good practice? Thank you
Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • Ayua Michael•530
    @TorCanHack
    Posted over 1 year ago

    Hi Weixin, congratulations on finishing the challenge 👏🏽 🎉

    I noted some observations you might find helpful.

    There’s no heading in your code. I can see the “html and css foundation” text is in a <p> tag. It is better you nest it in <h1> heading element as this is the most important text in the document. Search engines use the headings to index the structure and content of the webpage. Using headings help provide a structure and hierarchy.

    I also noticed you nested every <img> tag in a <figure> element. While the <figure> element is important, it serves no purpose in the present document. <figure> should not be used on decorative content like background images or supplementary images like an avi. You use <figure> to mark a self-contained element that is related to the main flow of the document, for example a diagram, or you use it when you need to caption an image. Since this in not the case presently. Using only the <img> with an alt attribute will suffice.

    The borders of the blog preview card are not meant to be sharp; they are curved. You can curve them in css using this:

    main {
    
    border-radius: 10px 10px;
    
    }
    

    Great work!

    I hope you find this helpful.

    Happy coding 🥂

    Marked as helpful
  • Bn-Bushra•290
    @Bn-Bushra
    Posted over 1 year ago

    Congrats on finishing this challenge. Here are my suggestions.

    Styling Challenges:

    1. Vertical and Horizontal Centering:

      • You've already used transform: translate(-50%, -50%) for vertical and horizontal centering, which is good.
      • Consider using flexbox for centering as well. It provides a cleaner and more flexible approach.
    2. Responsive Design:

      • Instead of fixed heights like height: 80dvh;, consider using relative units or media queries for better responsiveness.
    3. Width and Height Decisions:

      • Use relative units like percentages or viewport units for widths and heights to make your design more adaptable to different screen sizes.
    4. Overflow Issues:

      • Instead of setting a fixed height for the main container, consider letting it adjust based on its content. You can remove height: 80dvh;.
    5. Splitting CSS Code:

      • Your code is relatively short, but if it grows, you may consider splitting it into logical sections or using a preprocessor like Sass for better organization.
    6. Transition Duration:

      • Consider using a shorter transition duration for a more responsive feel, depending on your design preferences.
    7. Font Sizing and Units:

    • The use of rem for font size is a good practice as it allows for easier scalability. However, ensure that your layout remains readable on various screen sizes.
    1. Border Radius:
    • You've commented out the border-radius property in the main container. If you intended to use it, consider uncommenting and adjusting it based on your design preferences.
    1. Comments:
    • Your code has helpful comments, which is great for understanding your thought process. Keep it up!

    Example Adjustments:

    /* Centering with Flexbox */
    main {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      /* ... other styles ... */
    }
    
    /* Responsive Design */
    main {
      width: 90%; /* Adjust as needed */
    }
    
    /* Remove Fixed Height */
    main {
      /* height: 80dvh; */
    }
    
    /* Shorter Transition Duration */
    p, main:hover, .illustration:hover, .yellow-tag:hover, .avatar-picture:hover {
      transition: transform 0.3s;
    }
    
    Marked as helpful

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub