Hi ! I'm currently learning html and css for school and I tried to make this challenge only with my actual knowledge (a few hours of coding). I tried my best to make the page responsive but I'm not really sure I used the correct/best solution for that. I had some troubles with the mobile version, and I had to use a larger maximum width than recommended (375px to 800px now). I also found it hard to center horizontally and vertically the "main section", so it may not be perfect on every resolution. If you have any suggestion, I'm open for any advice !
Estifanos Wendimu
@Steeve26All comments
- @CN-WorksSubmitted over 1 year ago@Steeve26Posted over 1 year ago
Hey there 👋🏾. Great work! But it seems you haven't figured it all out so I'll shoot you some pointers. Also, feel free to check out my solution to the problem. It's got the proper HTML structure and efficient CSS to go with it.
let's start with your Html. Instead of section, I suggest you use the HTML tag <main></main> to hold the main content and another container for the whole QR code card as well as a container for the two text elements (refer to my solution). I also suggest you use classes for styling your HTML instead of ID.
Now about your CSS. I've noticed that you use all four properties of margin and padding separately a lot. It is much easier to just put them in one line like so: .mainBlock{ margin: 10px 4px 1px 12px} this means 10 top 4 right 1 bottom 12 right margin. You can also do this: "margin: 10px 12px" which means 10 top and bottom 12 left and right. And the same goes for padding.
Something else I've noticed is you using percentage values a lot. It isn't usually necessary to use percentage values unless you don't know exactly how much the value of something should be (like when you want the qr code card thing to be 95% of the screen width for small devices which is what I did.) It can be a bad idea like how you used it for the border radius values which makes it a little wonky. always use exact values for that (3px - 10px is usually enough)
And finally, about centering content. You need to get yourself familiar with flexbox as it will be your go to method for centering 90% of the time. All you have to do is "display: flex; align-items: center; Justify-content: center;" on the container elements (the 'main' container in this case, which you replaced with 'section') And their content will be centereď on both axes. Though keep in might displaying flex will arrange child elements horizontally. which you can counter with 'flex-direction: coulmn'.
And one more thing, What you did with the media query is apply that CSS to all devices under 800px but the content is so small that It won't need adjusting until you get to the under 400px range. So if you're looking to target phones, go for under 500px. Hope this clarifies things ✌
0 - @taco-nekoSubmitted over 1 year ago
So I have a few things I struggled with or am confused about:
- I used rems for most of the sizing. I think that should be fine? I'm not entirely sure on when to use what unit.
- I'm not sure about what the best accessibility practices are when it comes to QR codes. I put alt text on it to mention where it leads to, but I'm not sure how someone using a screen reader would actually use it. I've gone more into detail about this on the repo page.
@Steeve26Posted over 1 year agoSo 'rem's(16px) adjust your content based on the root font-size while 'em's(16px) adjust based on the element font-size. So if a div has elements with '3em' values inside, and you make the div's font size '10em' the child elements will have values of 10em X 3em = 30em (480px)
1