Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 2 years ago

QR Code card with HTML and CSS

Camila B•30
@camilabandeira
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Putting together that webpage took a bit of time, but it was all worth it. I had so much fun working on it and feel like I learned a lot in the process.

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Lucas 👾•104,160
    @correlucas
    Posted over 2 years ago

    Oi Camila, tudo bem?

    Tenho algumas dicas pra você:

    1.Vi que você usou em e rem e isso é mto bom, usando essas medidas relativas ao invés de px se você tiver que escalar o tamanho dos elementos depois ou o usuário der zoom na tela, todos itens vão crescer proporcionalmente, eu só te recomendo usar uma medida só, nesse caso vc pode usar sempre REM. Outra dica é usar um plugin do VSCODE chamado PX TO REM, que converte automaticamente todos elementos escritos em PX para REM, basta selecionar e apertar alt + z. Aqui o link: https://marketplace.visualstudio.com/items?itemName=sainoba.px-to-rem

    2.O seu componente já está com o design pronto, um bom exercício pra melhorar seu código, seria criar a estrutura mais limpa o possível e reduzir seu código ao máximo. Por exemplo, você pode segurar todo conteúdo em um bloco só usando (<main> ou <div>) nesse caso vamos usar <main> por que é uma tag semantica. Se você notar, nem precisa adicionar nenhum div além da principal pra segurar o conteúdo (img, h1 e p). A estrutura ideal e mais limpa possível pra esse desafio é essa aqui:

    <body>
    <main>
     <img src="./images/image-qr-code.png" alt="QR Code Frontend Mentor" >
    <h1>Improve your front-end skills by building projects</h1>
    <p>Scan the QR code to visit Frontend Mentor and take your coding skills to the next level</p> </main>
    </body>
    

    Para reduzir o CSS, você pode excluir todas as classes e selecionar todos elementos no CSS com o seletor direto para cada um deles, nesse caso (img, div, main, h1 e p). Faltou também colocar o alt text pra imagem ser reconhecida por leitores de tela.

    2.Você definiu o tamanho do card com max-width e isso é bom, pois deixa o container responsive, mas por conta de vc ter colocado o width dentro do html, a imagem ficou com aquele tamanho fixo, o ideal seria vc usar max-width: 100% pra imagem ter o tamanho de 100% do elemento pai e não crescer mais do que isso e diminuir juntamente com o resto de acordo com a tela. Lembre-se de usar sempre max-width quando vc quiser que um elemento tenha um tamanho limite e possa diminuir, ou seja, responsivo, use width somente quando vc quiser que ele tenha tamanho fixo.

    img {
        max-width: 100%;
    }
    

    3.Para separar os elementos, vc pode usar sempre padding-bottom ou margin-bottom para separar verticalmente os elementos, desse jeito vc adiciona esse propriedade de cima pra baixo e quando precisar mudar algo basta olhar o elemento de cima. Para criar um espaçamento de padding uniforme com a imagem vc pode definir um padding pro container de 16px por exemplo pra criar uma borda interna entre todos elementos, desse jeito vc so precisa se preocupar com os paddings verticais.

    Aqui minha solução caso você queira usar como referência: https://www.frontendmentor.io/solutions/qr-code-component-vanilla-cs-js-darklight-mode-nS2aOYYsJR

    Espero ter ajudado e continue no foco, vc já começou muito bem, a maioria das pessoas não acertam o design e o seu ficou perfeito, só fazer alguns ajustes e reduzir a estrutura do html deixando o codigo mais limpo e vai ficar perfeito. Parabéns ✌

    Marked as helpful
  • Ahmed Mohsen•230
    @ahmed-mohsen88
    Posted over 2 years ago

    Hello Camilla Congratulations for completing your first task. Your design is fantastic, and I really like how similar it is to the original.

    To avoid the warning, change the div class attribute to the footer tag, and modify the width of the image to "px" rather than "p."

    Hope that was helpful

    again, congratulations

    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