@josifermaodev
Posted
You can make your design responsive without using media queries by using a few different approaches. Here are a few techniques that can help:
1. Flexbox and Grid Layout:
Both are great tools for creating flexible layouts that automatically adjust to the screen size.
2. Relative Units:
Using relative units like em
, rem
, vw
, and vh
can make your design more adaptable to different screen sizes.
em
and rem
: Proportional to the font size of the element or root.
vw
and vh
: Proportional to the width and height of the viewport.
3. CSS Functions:
CSS functions like calc()
, min()
, max()
, and clamp()
help you create dynamic values that adjust to the context.
4. Aspect Ratio:
Maintaining the aspect ratio of elements can help you create designs that automatically adjust.
5. CSS Custom Properties (Variables)
Using CSS variables allows you to dynamically adjust your design based on global variables.
These techniques can help make your design more flexible and adaptable to different screen sizes without relying solely on media queries.
Analyzing your code
I noticed an unnecessary overuse of tags:
<div>
there is no need to make so many divisions, a better way to deal with tags is to give classes to each one of them.
<h1>
It is better to use only one <h1>
per page to maintain the correct semantic hierarchy and use <h2>
, <h3>
, etc., for subtitles.
Instead of repeating tags to perform line breaks using the responsiveness methods above, by automatically delimiting the space you will already have responsive code.
Here is an example of how to make the code cleaner and more functional:
<div class="container">
<div class="container__main">
<img src="/images/image-qr-code.png" alt="Qrcode Frontend Mentor" class="container__main-image">
<h1 class="container__main-title">Improve your front-end skills by building projects</h1>
<p class="container__main-text">Scan the QR code to visit Frontend Mentor and take your coding skills to the next level</p>
</div>
</div>
Hope this helped!