Making your HTML responsive using simple CSS

Imtiaz Mahmod
2 min readDec 25, 2021
Responsiveness

In this article, I will teach you how to make your HTML website responsive using simple CSS Grid.

Write HTML for following website like that:

HTML

And CSS :

CSS

In following CSS code, grid-template-columns: 30px 30px 30px; HTML not responsive. So, We should bit change. Responsiveness with fractional unit. Fractional unit is one kind of unit like pixel, centimeter etc.

Fractional unit is written as fr. It allows to split container that you want. So, let a bit change our CSS. Code is:

Grid using fractional unit

In this following code, container width split into three portion responsively. Like following below:

Responsive grid

Here three column is responsive according to width. We change this only grid-template-columns by fractional unit. Also we get this responsiveness using repeat( ) function. Like this code:

Using repeat( ) function

What happen in this code section, repeat function has two parameter. First parameter is for number of column and second parameter for width size of column. On the other hand, repeat(3, 1fr) means (1fr 1fr 1fr). Repeat three column according container width by one fraction.

Thank for reading! My name is Imtiaz. I’m an innovative web developer. Follow me on LinkedIn if you want to keep in touch.

--

--

Imtiaz Mahmod
0 Followers

✨𝗟𝗼𝗰𝗮𝗹 𝗦𝗘𝗢 𝗦𝘁𝗿𝗮𝘁𝗲𝗴𝗶𝘀𝘁 💼 𝗚𝗕𝗣/𝗚𝗠𝗕 𝗠𝗮𝗻𝗮𝗴𝗲𝗺𝗲𝗻𝘁 👉 𝗛𝗲𝗹𝗽𝗶𝗻𝗴 𝗟𝗼𝗰𝗮𝗹 𝗕𝘂𝘀𝗶𝗻𝗲𝘀𝘀 𝗥𝗲𝘃𝗲𝗻𝘂𝗲 𝟭𝟬𝘅