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

Product preview card component

CarlosJoaquim•100
@CarlosJoaquim
A solution to the Product preview card component 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?

Do que eu mais me orgulho:

Design Responsivo: Achei incrível como consegui fazer o layout se adaptar tão bem a diferentes tamanhos de tela, especialmente com a media query para dispositivos móveis. A troca da imagem de fundo e a reorganização dos elementos em coluna para telas menores que 600px ficaram muito boas.

Uso de Unidades Relativas (vh): Gostei de ter utilizado unidades relativas como vh para garantir que o layout seja flexível e se adapte a diferentes resoluções.

Estrutura Semântica do HTML: A organização do HTML ficou clara e semântica, com o uso adequado de tags como <main>, <div>, <p>, <h2> e <button>. Isso facilita a leitura e a manutenção do código.

Estilização do Botão: O botão ficou visualmente atraente, com um efeito de hover que melhora a experiência do usuário. A inclusão do ícone de carrinho também foi um toque interessante.

Uso de clamp() para Fontes: Achei inteligente o uso da função clamp() para o tamanho das fontes, garantindo que elas se ajustem de forma responsiva.

O que faria diferente na próxima vez:

Correção de Pequenos Erros: Notei que há alguns valores repetidos no CSS, como a declaração de font-size para h2 e p na media query. Na próxima vez, revisaria o código para evitar redundâncias.

Melhor Organização do CSS: Separaria o CSS em seções mais claras, como "Reset", "Estilos Gerais", "Componentes" e "Media Queries", para facilitar a leitura e a manutenção.

Uso de Variáveis CSS: Utilizaria variáveis CSS para cores e tamanhos, o que facilitaria a consistência e a alteração de estilos no futuro. Por exemplo, definir --primary-color: #1A4031; e usar essa variável em todo o código.

Testes em Mais Dispositivos: Faria testes em mais dispositivos e navegadores para garantir que o layout funcione perfeitamente em todos os cenários.

Acessibilidade: Adicionaria atributos ARIA e melhoraria o contraste de cores para garantir que o site seja acessível para todos os usuários, incluindo aqueles com deficiências visuais. Por exemplo, garantir que o contraste entre o texto e o fundo atenda às diretrizes WCAG.

Otimização de Imagens: Consideraria usar imagens em formatos mais modernos, como WebP, para melhorar o desempenho de carregamento.

Refatoração do Código HTML: Simplificaria a estrutura do HTML, reduzindo o número de divs aninhadas onde possível, para tornar o código mais limpo e fácil de manter.

No geral, estou muito satisfeito com o resultado, mas sempre há espaço para melhorias! 😊

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

Um dos principais desafios que enfrentei foi garantir que o layout permanecesse responsivo e visualmente agradável em diferentes tamanhos de tela. Inicialmente, o design estava ótimo em telas maiores, mas ao testar em dispositivos menores, percebi que alguns elementos, como a imagem e os textos, não estavam se alinhando corretamente.

Para superar isso, implementei uma @media (max-width: 600px) para ajustar o layout em dispositivos móveis. Mudei a direção do flexbox de row para column dentro do #area, garantindo que a imagem e o texto se organizassem corretamente um abaixo do outro. Além disso, precisei ajustar as propriedades de border-radius para manter a transição suave entre as seções ao alternar entre os layouts.

Outro desafio foi fazer com que os tamanhos de fonte escalassem bem. No início, o uso de valores fixos para font-size causava inconsistências entre diferentes dispositivos. Resolvi isso utilizando clamp() e unidades vh, permitindo que o texto se ajustasse dinamicamente ao tamanho da tela, melhorando a legibilidade e a experiência do usuário.

What specific areas of your project would you like help with?

Gostaria de ajuda em duas áreas específicas:

Otimização do CSS – Acredito que algumas regras podem ser simplificadas para reduzir repetições e melhorar a escalabilidade do código. Talvez seja possível substituir algumas propriedades redundantes ou agrupar seletores para tornar o código mais eficiente.

Melhoria na responsividade – Embora eu tenha implementado um @media (max-width: 600px), gostaria de sugestões para tornar o design ainda mais adaptável, garantindo uma melhor experiência em telas intermediárias, como tablets. Além disso, gostaria de saber se há maneiras mais modernas ou eficientes de gerenciar a responsividade sem depender tanto de media queries.

Se houver outras melhorias que você perceba no código, também estou aberto a sugestões!

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Kate•60
    @ClickClickKate
    Posted 6 months ago

    Hello

    I like that your code is very well organised, this make it easy to read.

    I would suggest using padding and/or margin to provide space around text items. I would also suggest trying to experiment with line height to make some text closer together like the H2.

    You don't seem to have set the font for the different components? Unless i'm missing it. I usually link the font's I need into the html sheet.

    I think you are really close to it being the same and a bit of playing around could get it there. I found this exercise a bit awkward!

    Look into CSS variables if you get the chance, when I discovered this it saved me so much time.

  • Marcos Travaglini•6,230
    @Blackpachamame
    Posted 6 months ago

    Greetings! you have done a great job 😎

    📌 Some suggestions

    • Use min-height and max-width, this will help the content stretch or shrink if you need to. Unlike height and width which can cause your content to be cut off on certain screens. For example, use min-height: 100vh instead of height: 100vh
    • Do not use % for width or height. Better use rem, em or px
    • Don't use vh or vw to define the dimensions of a property. Only use them for specific cases like the min-height of your main
    • You have two elements with the same card class, this can be a problem
    • A good tip for naming CSS classes is to use the BEM methodology
    • The image is part of the card, so you should not place it as a background, but as another element of the card
    • You can use the <picture> tag to change the image according to the screen size. More info

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

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