CSS Tutorial — Relative Sizes, Percentage % (7/13)

preview_player
Показать описание
CSS Tutorial — Relative Sizes, Percentage % (7/13)

Relative size is huge. The first one I wanna show you is percentage. AAAAAA this is a good one. You can say width: 50%. That’s legit CSS. But wait, 50% of what? Good question...
Say we have P tag. I’ll give it a red background so we can see where it starts and where it ends. You should do that too. P tags by default are block level elements, I explain more here. so they take up the whole row. Their width is 100% of their parent. So by default it’s kinda like the P tag has an invisible rule on it that says width: 100%.
They kinda just adjust to their containing parent element. Now what if I change the width to 50%; What if I add that to my CSS? BOOM. Look at that. Now it’s half the size. Wait, again, half the size of what?
In this case the containing parent of our P tag is the body, I’ll add a green border to body so you can see. when I resize the window the body is getting smaller & bigger, but the width value that we gave our P tag stays 50%, relative to the body. Because it’s its parent. So when I resize the window, my P tag will automatically resize itself to be 50% whatever the body is.
This is a technique used in responsive web design. It’s extremely useful. It’s not the end all be all, there are times where you don’t want a relative value, but if I used absolute values for width and height, my element might look great on one screen, but be completely unusable in a smaller device.
So it’s safe to say relative values are mostly used to support different screen sizes. I don’t want you to worry about responsive web yet, it’s a whole course in and of itself, and I promise we’ll get there.
There are other very important relative units I wanna show you, EM and REM, they are absolutely essential in sizing your text, something I brought up already. And that’s coming up next. Let’s go get it.
Рекомендации по теме
Комментарии
Автор

I was confused between % and px. When I searched I found long length videos and skipped those. But
I felt interested about your 2:35 minute videos and thought I can watch. After watching it all my confusion went away.
Please keep continuing.

rezaulkarimraihan
Автор

Slick editing, concise video, and good content here. Well done! 👍🏻

muygalan
Автор

THANKS GOD I FOUND THE NAME I'VE BEEN SEARCHING FOR MONTHS LOL THIS IS THE PROBLEM I'VE ENCOUNTERED ALWAYS WHEN I OPEN MY DESIGN ON A SMALLER SCREEN, SO I GOTTA FOCUS NOW ON RELATIVE SIZES TOPIC AND PERCENTAGE!!!

icaruz
Автор

Amazing video! You keep it short and straight to the point with great charismatic elements! It really is great as you don't need to take the whole CSS course to just find about relative sizing, just what I needed!

kerwin
Автор

How to avoid breaking of css layout when we zoomin or zoomout plz tel me

krishnajikulkarni
Автор

Good video well explained, but I can’t understand what you think the music adds to the video, for me it’s just a distraction

higgsy
Автор

Hi Sina, Can you explain the difference between top and margin-top?

SiddharthRay
Автор

Hello, Can you explain that 'top' in percentage ? I know it mean 'A <percentage> of the containing block's height.' but what is the containing block?

yylifehuang
Автор

understanding of css it's huge but these day company just want below average UI developers. can you image position of UI required java and dot net as well. How insance is that. How a backend guy can make good UI layouts. at the end they are reducing the quality of product.

SiddharthRay
Автор

bro you can make group in whatsapp to solving our problems

hhg