Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 10 months ago

blog-preview-card

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

Solution retrospective


What are you most proud of, and what would you do differently next time?

project demonstrates a well-structured and responsive design for a card component. Here’s a quick breakdown of your implementation:

CSS Variables: You've used :root to define colors, making the code easy to maintain and adjust globally. It's a good practice to centralize your styles.

Fonts: You've imported custom fonts using @font-face, ensuring your design has a consistent look across different devices. However, be sure to include fallback fonts in case the custom fonts fail to load.

Flexbox Layout: You're using Flexbox to center content, which ensures responsiveness. The use of flex-direction: column makes the layout stack the content vertically, ideal for card components.

Responsive Design: The media query adjusts the layout on smaller screens (max-width: 375px). This ensures a great user experience across devices.

Card Styling: The card styling is clean with rounded corners, shadows, and hover effects, making it visually appealing.

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

Challenges Encountered: Font Loading and Compatibility:

Initially, I faced issues with custom fonts not loading consistently across browsers and devices. The fonts would often fail to display properly or cause delays in page rendering. Solution:

I ensured that the correct font formats (.woff, .woff2, .ttf) were provided for better browser support. I also included fallback fonts in the font-family declaration for cases where the custom font isn't available. Responsive Design on Smaller Screens:

At first, the card component wasn’t responsive enough on smaller screens. The card’s width and font sizes were too large, causing overflow and poor readability on devices with smaller screen sizes. Solution:

I used media queries to adjust padding, font size, and width of the card container based on screen width. This made the design more adaptable to different screen sizes. Aligning Elements Using Flexbox:

There were alignment issues where the card’s content would shift unexpectedly, especially when the content length varied. Flexbox was a bit tricky at first in making sure everything stayed centered and aligned. Solution:

I utilized flex-direction: column along with justify-content: center and align-items: center to ensure proper vertical and horizontal centering. I also tested on multiple screen sizes to ensure the design was stable. What I Learned: CSS Flexbox is a powerful tool for responsive layouts, but it requires careful attention to detail, especially with dynamic content. Font management can be tricky, but using multiple formats and fallback fonts ensures a smoother experience for users across different platforms and browsers. Where I Need Support: Cross-Browser Compatibility: Ensuring that custom fonts and CSS properties render well on all browsers is still a challenge. Any tips on testing and troubleshooting compatibility issues would be helpful. Optimizing Performance: I'm looking to optimize font loading for better performance, especially on mobile devices. Techniques like font-display: swap or lazy loading might help, but I'm not sure how to implement them effectively.

What specific areas of your project would you like help with?
  1. Font Loading Optimization Question: How can I optimize the loading of custom fonts (@font-face) to improve page load speed, especially on mobile devices? Issue: The fonts sometimes take time to load, especially on slower connections. I’d like to use strategies like font-display: swap or preload but am unsure how to implement them correctly.
  2. Cross-Browser Compatibility Question: What are the best practices to ensure custom fonts and Flexbox work consistently across all browsers (including older versions of Internet Explorer and Firefox)? Issue: I’ve noticed some inconsistencies in how the fonts and Flexbox layout render on different browsers. Any advice on tools or methods to test and resolve these issues?
  3. Mobile Responsiveness Question: How can I further improve the card layout for very small screens (e.g., below 320px) without making text too small or elements overflow? Issue: While the layout is mostly responsive, on very small screens the card looks cramped. I'm unsure if I should reduce font sizes or tweak spacing further for better readability and layout.
  4. Performance Enhancements Question: What strategies can I use to improve the overall performance of this page, particularly in terms of images and fonts? Issue: I am concerned that large font files and images could be slowing down the page. How can I reduce the page load time without compromising design quality?
  5. Accessibility (a11y) Question: Are there any accessibility improvements I should make to the card and overall page to ensure better user experience for people with disabilities? Issue: I want to make sure that my project is accessible and follows best practices (e.g., proper alt text for images, correct semantic structure).
Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on AnkitSinghSenwal's solution.

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

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

Frontend Mentor

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

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