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

QR Code component with flexbox and custom properties

Franck Bigandβ€’ 20

@FranckBigand

Desktop design screenshot for the QR code component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


Hello, Does anyone has a better solution for fixing the footer at the bottom of the page ? What I wanted to achieve was:

  • If content of page is small (less than screen height), let footer at the bottom
  • If content of page is large (bigger than screen height), let footer at the bottom, but we the need to scroll the content to be able to see it

Community feedback

Raza Abbasβ€’ 790

@RazaAbbas62

Posted

To achieve the desired behavior of fixing the footer at the bottom of the page and allowing it to be visible when the content is smaller than the screen height or requiring scrolling when the content is larger, you can use a combination of HTML and CSS. Here's an example:

HTML structure:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="styles.css">
  <title>Your Page Title</title>
</head>
<body>
  <div class="wrapper">
    <!-- Your page content goes here -->
    <div class="content">
      <!-- Your actual content -->
    </div>
  </div>
  <footer>
    <!-- Your footer content goes here -->
  </footer>
</body>
</html>

CSS styles (styles.css):

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrapper {
  flex: 1;
}

footer {
  background-color: #f0f0f0;
  padding: 10px;
  position: sticky;
  bottom: 0;
  width: 100%;
}

Explanation:

  1. The body element is set to display: flex and flex-direction: column to ensure that the main container (wrapper) takes up the available vertical space.

  2. The wrapper div is given flex: 1 to take up the remaining space and allow the footer to be pushed to the bottom.

  3. The footer is set to position: sticky and bottom: 0 to make it stick to the bottom of the page. It will remain at the bottom even if the content is smaller than the screen height.

  4. The min-height: 100vh on the body ensures that the body takes at least the full height of the viewport.

With this setup, the footer will be fixed at the bottom of the page for small content and will be visible without scrolling. For larger content, you will need to scroll to see the footer. Adjust the styles according to your design preferences.

2
Hassan Moatazβ€’ 1,860

@hassanmoaa

Posted

Hello @FranckBigand!

Great Job solving the challenge mate congrats πŸŽ‰

Some suggestions for improvements.

For the font-size it's is better to use rems and ems but px for this project is no big deal.

font-size: 13px;

  • i see you using pixels for many elements, never use pixels for font-sizes in any element, here's why:

  • Certain font-related CSS properties will render your site completely inaccessible if their value is declared using pixels even once.

Which properties are affected?

All of these properties must never ever be declared in pixels:

  • font-size
  • line-height
  • letter-spacing

If you've used pixels to define any of the above style properties, these will not respect the user's font size preferences!

  • You should use ems, and rems for font-sizes would be better

This article may help:

https://fedmentor.dev/posts/font-size-px/

βž–βž–βž–βž–βž–βž–βž–βž–

Other than that you're good, keep up the good work!

1
Olaniyi Ezekielβ€’ 7,560

@Ezekiel225

Posted

Hello there πŸ‘‹ @FranckBigand.

Good job on completing the challenge !

Your project looks really good!

I have a suggestion about your code that might interest you.

There is an very useful browser extension called Perfect Pixel that allow you compare with the design image and thus see the exact dimensions. I recommend it to you.

I hope this suggestion is useful for future projects.

Other than that, great job!

Happy coding.

0

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