visit
As a Microverse student for one month, I realized that my first clone webpages didn’t have a responsive layout. I was using pixels in the Navbars, percentages in one section and rem in another, I didn’t have a rule or a standard procedure. The goal was to make it look like the original webpage IN MY SCREEN.
As I advanced through the course, I learned that these units made all the
difference to the webpage’s response in different screen sizes. My code
reviewers would tell me to adjust my webpage because it looked different when they were viewing it.
When I started having these issues, I made a lot of research on the subject,
but I was still a little confused about it. This article’s goal is to create a
simple and direct rule to achieve the required responsiveness any developer needs in their code.
Right now, I am using a Lenovo Ideapad S145 to write
this article, it has a screen size of 15.6” and the Hackernoon webpage looks
like this:
To solve our problems, we have a lot of solutions. In
this article, I’m going to focus on two of them:
• Relative units (rem, em, and percentage);
• Media queries.
When using CSS properties like font-size, width, height, margin or any other that needs a size unit, you have some options, and they are divided into two groups: relative units like rem, em and percentage () and fixed units like pixels. The first group is the one we should be using, and
the images below show why.
Can you see the scroll bar? That happens because the top box has a fixed unit value, so its width goes on even if we shrink the window’s size. The bottom box has a percentage value, it responds to the change in the window’s size.
This is the first solution on making your webpage more responsive, but we are not quite done yet, we can improve our projects even further, take a look at the next section!
Terrific, the scroll bar is gone, as is the navbar! The thing is, now this page used that menu button (top green area, beside the light icon) which, when clicked, provides that same navbar vertically, isn’t it awesome?
If you want to see the results of your work with ease, you can use Google
Chrome’s Developer Tools and access the Device Toolbar where you can play with the window’s width and see how the changes are applied in each media query breakpoint.
In this article, I tried giving you the basic concepts of some of the tools needed for building a responsive webpage. But if you need a more detailed step-by-step guide, I recommend you to watch this () from TutsPlus.
This article shouldn’t be your only source of information, you should take a
look at the links I provided and make some more research before jumping into your project. And never do it like . Happy coding!