Тёмный

CSS Units: vh, vw, vmin, vmax  

Kevin Powell
Подписаться 943 тыс.
Просмотров 202 тыс.
50% 1

A look at the viewport CSS units vw, vh, vmin and vmax. Not only do I look at how they work for layout purposes, but how they can be really useful for setting type as well!
My Codepen: codepen.io/kevi...
---
Music by Chillhop: / chillhopdotcom
L'Indécis - Happy Hours: / lindecis
If you have your own channel, check out Chillhop for some awesome music.

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 243   
@rawnoob2143
@rawnoob2143 6 лет назад
Note to self: the difference between vw (or vh) and percentages is that vw and vh are relative to the viewport whereas percentages are relative to the parent element.
@samuelwong6352
@samuelwong6352 2 года назад
best comment ever
@adreenazea9015
@adreenazea9015 Год назад
@@samuelwong6352xh Cad Cb Vcr c km Gj X C nda ca c8 cm C V8c v pi bad H h Cah j bdi cb Fi bc8bcn Be gb ci vf cm c V
@adreenazea9015
@adreenazea9015 Год назад
Cg n IBM V 🐼c set gbf c ✨💎💎✨💎💎✨ 💎💎💎💎💎💎💎 💎💎💎💎💎💎💎 ✨💎💎💎💎💎✨ ✨✨💎💎💎✨✨ ✨✨✨💎✨✨✨ 8-) Vb G
@adreenazea9015
@adreenazea9015 Год назад
@@samuelwong6352 vbhb
@adreenazea9015
@adreenazea9015 Год назад
Bismillah vgg itu vv. Cgvj
@nuttaphonr.6498
@nuttaphonr.6498 3 года назад
Thanks for great explaing :3 6:14 vmin 6:58 auto adjust padding based on vh 7:37 setting font size with vw 9:40 problem with setting font with vw and vh 10:54 using vmin to set fontsize (very useful)
@The-Heart-Of-It
@The-Heart-Of-It Год назад
A neat trick is to set the font size on the parent element to 1vw and then use em on the child elements to get everything responsive at different widths.
@truefisherking
@truefisherking 5 лет назад
I use: font-size: calc(Xvw + Yem); X and Y = two numbers. Example: calc(0.5vw + 1em); The cool thing is, you can easily control 'how responsive' the text will be. Sorry if you already have a video with this method. I haven't watched all your videos (you rock BTW), and I haven't seen this technique anywhere else. Thanks for the excellent content. I've learned so much.
@LucianoFalettiplus
@LucianoFalettiplus 4 года назад
Have you ever used calc (Xvw + Yvh) ?
@truefisherking
@truefisherking 4 года назад
@@LucianoFalettiplus I've played with it, but I wanted a method that mimicked (mx + b). I wanted a constant, but it makes sense to use Yvh. In theory, a constant is better, but in practical use, if a user is trying to view your page in a manner that makes the text too small to read, then they probably can't see anything anyways.
@albirtarsha5370
@albirtarsha5370 3 года назад
This is better as it resembles y=mx+b
@mohamedelidrissi2839
@mohamedelidrissi2839 4 года назад
I heard you read all comments, even those in videos that are 2 years old, so I just wanna say hi and thanks for the well explained videos!
@reshairo
@reshairo 3 года назад
now 3 year 😉
@keshav2136
@keshav2136 3 года назад
Hi
@pedhead
@pedhead 3 года назад
@Kase Jaziel wut if you don't have a GF? #foreveralone 😭
@mukeshrap6sm27ezdaguraopp6
@mukeshrap6sm27ezdaguraopp6 3 года назад
Ttþoo88t
@sueholder703
@sueholder703 3 года назад
I have started using vw for my body font-size because I use rem and em's and I use vw vh for divs but this is a whole new level and so exciting. Thanks for bringing these tips that make everything make that much more sense. You definitely help make the corners of the web that much better. ;) See you in the next one!
@ayo.eleven
@ayo.eleven 5 лет назад
I just wanted to comment something as it helps grow the channel. Your tutorials are so awesome that there is hardly anything I can write here that doesn't make me feel silly :) Wish you lots of luck!
@TheJacklwilliams
@TheJacklwilliams 2 года назад
Kevin, as I work through CSS and apply these things to a site I'm building (my portfolio site, etc...) I've found very quickly mastering what units to use for what elements is well, damn important. Thank you for the lesson(s).
@subfreeman9778
@subfreeman9778 2 месяца назад
Thanks alot, although the vmax and vmin is making me go crazy, but i love the entire concept
@surajitdas94
@surajitdas94 6 лет назад
Hey Kevin. Thanks for all the good stuffs. Love form India.
@doctorartiste2905
@doctorartiste2905 Год назад
CRL - Conquering Responsive Design - Day #4 - Extra Credit! 🖥
@antives8584
@antives8584 2 года назад
These videos are really changing the way I handle CSS design. My techniques was always based off from elementary courses all explaining the basics, however these are real world experience coupled with a great way of teaching! Thanks, Kevin, these videos are really helping me (and many, I'm sure) to become better developers :D
@saguoran
@saguoran 5 лет назад
I was looking for the video "vh vs em css", RU-vid gave me this one. Thanks Kevin, I have better understanding of them.
@markcook8516
@markcook8516 Год назад
This is a video to remember, having seen, when I might someday come across this concern. I am so new to CSS and realizing how powerful it is. Organizing all my notes, so that I can quickly find previous points of interest is my most pressing issue. Robert Pirsig's book: comes to mind and all the notes that the narrator kept.
@davidserranoii4114
@davidserranoii4114 4 года назад
Thank you for your vids, but, i have a question about the beginning of the video. I noticed you said (height: 100vh) may cause issues with smaller phone sizes since contents could overflow outside the box, and you suggested a media query as a solution. Could it be a possible solution to use the (min-height: 100vh) instead of a media query so that the box will be responsive if the contents start to overflow or would that make the height too small, and only go to 100vh once the screen is smaller? Thanks again for the vids, currently doing your "Conquering Responsive Layouts"
@calvitocalvon1711
@calvitocalvon1711 3 года назад
I think these can be more troublesome than helpful! you open yourself to a lot of unwanted results, i think em and rems and percentages should be solid
@almonddaves
@almonddaves 6 лет назад
Thank you so much! You make this tutorials really fun and I actually enjoy learning about all this! My layouts will look better than ever thanks to you!
@jcespinoza
@jcespinoza 4 года назад
Just commenting to say hi :) And thanks for the tutorial. I feel I'm finally on the right track to becoming a front-end dev with these videos!
@adolfojbarreto5021
@adolfojbarreto5021 5 лет назад
I can't believe I missed this video when you published it! The aggravation this would have saved me, Kevin. I have a patch of grey hair due to this issue. Thanks again!
@Leonebert
@Leonebert 2 года назад
I think it could be possible to set the min and max font sizes with clamp() instead of a media query.
@pottingshedgene
@pottingshedgene 4 года назад
Yet another super clear explanation Kevin. Superb.. Thank you again. STILL enjoying your 21 day course. Try it folks it's ace.
@yasirtahirkheli74
@yasirtahirkheli74 5 лет назад
easy, simple and elegant explanations....you are probably the best instructor for css i have ever come across...Kevin...stay blessed
@KevinPowell
@KevinPowell 5 лет назад
Thanks ks so much for the kind words, so glad that your enjoying my videos 😁
@VideoMo2000
@VideoMo2000 Год назад
Great video! I was using vh for my header most of the times but never tought about using vw for responsive Titles. You are the reason I dont hate CSS as much as I used to.
@leticiaespino7251
@leticiaespino7251 2 года назад
Awesome content Kevin. Thanks for your hard work and for all the effort you put into this.
@oluwaseunogundipe1531
@oluwaseunogundipe1531 2 года назад
great video Thanks for sharing
@milleniummoses
@milleniummoses 6 лет назад
I've a good portion of today and yesterdya watching yoru videos. I've learned so much. It's like my skillset adn efficiency exponentially improved overnight. THANKS!
@KevinPowell
@KevinPowell 6 лет назад
That's great to hear David, I'm glad my videos are helping you out! Always humbling to know some people are binge watching my stuff!
@wais4148
@wais4148 5 лет назад
it really helped me, tnx a lot man! I like ur explanation method (from Afghanistan)
@pika7037
@pika7037 6 лет назад
Please make a video on box-sizing: border box concepts and how we use it in real life....Thank you so much
@KevinPowell
@KevinPowell 6 лет назад
Another good suggestion, thanks.
@oxi7576
@oxi7576 2 года назад
When you're working with vh/vw/vmin/vmax in typography and you need to set a minimum font size (so it doesn't get too small), you can always add a static value to it with calc and make sure it never goes under that value, e.g.: font-size: calc(1em + 2.5vh) This should allow it to proportionally resize to the viewport height, but make sure that it is always at least 1em in situations where the viewport height becomes too small. My proposal doesn't take in account screen sizes that get too BIG though, so perhaps that would require a media query of its own. But hey, I guess that counts for mobile-first design.
@itsPenguinBoy
@itsPenguinBoy 2 года назад
that's where clamp() comes in
@jason0ng
@jason0ng 4 года назад
Really useful tutorial, cleared up a lot for me! Thank you.
@cgungm
@cgungm Год назад
Thank you, Kevin. You have a rare talent for explaining what could be very complicated into something more easily digestible.
@invictusathlete1783
@invictusathlete1783 3 месяца назад
I think media queries are the best choice for typography, but you can also use calc(...vw + ...rem)
@regbarnard2866
@regbarnard2866 4 года назад
Thanks Kevin another great video, I am working through them. Excellent CSS and HTML content, cheers
@clevermissfox
@clevermissfox 11 месяцев назад
If you set a fontsize of 1vmin or 1vw on your wrapper, then using ems for padding, margins or even font size on everything within could be useful? Idk ill have to see. That was my first thought anyway
@johngreenacre4578
@johngreenacre4578 Год назад
Just watched as part of the "Conquering Responsive Layouts" course, and just wondering if an update with the dvw and dvh would be worthy, or just note that it takes into consideration of elements on the screen of mainly mobile devices?
@edwin6294
@edwin6294 2 года назад
i'm thinking about the image responsiveness.bcos adjusting the units affects the image.did kevin say about this?
@silkeschumann7261
@silkeschumann7261 5 лет назад
I like to use it for any font on combination with calc() this way I can prevent it from getting too small but still have it responsive to screen size.
@newmanadesan9964
@newmanadesan9964 Год назад
I really enjoyed this video, I am learning a lot from your course. thank you for making it free. I just am a young front end developer hoping to break into the industry. This is good content.
@junaid7083
@junaid7083 Год назад
very well explained👏 use vmin for p use vw in titles for dynamically adjusting titles
@nirdesh5431
@nirdesh5431 5 месяцев назад
Not a great explanation! Better to practise off camera before making such videos where you are confused yourself and you do ahhh ummmm ehhhh etc
@bollvigblack
@bollvigblack 4 года назад
this is brilliant. you not only show us what code does but tell us how can we use simple code like this in a a different situations which is super useful !
@vertigoz
@vertigoz 4 месяца назад
The thing is, when the screen get small, such as in a mobile screen, one sees it way closer then it would on a monitor, so it could actually be a good size, dependent of the medium being watched, that is...
@ishmaelsunday6238
@ishmaelsunday6238 3 года назад
Why did you use EM for the hero text instead of REM? Look at the code you will what I am talking about.
@JonHyatt_UT
@JonHyatt_UT 5 лет назад
Super useful... especially as I'm working on understanding modern design using CSS
@pfever
@pfever 4 месяца назад
In newer videos you mentioned you almost never use viewport units. So you changed your mind with the years?
@mauriciovargasrincon3368
@mauriciovargasrincon3368 10 месяцев назад
An updated video on the handling of these viewport units would be wonderful. Thanks ;)
@naziyatarannum7196
@naziyatarannum7196 2 года назад
Thanks for sharing that Kevin😊. I follow ur channel n it’s really useful
@utkarshkukreti239
@utkarshkukreti239 5 лет назад
Thank you Kevin. It was good from both practical and theory.
@anandcherian.585
@anandcherian.585 3 месяца назад
very useful
@etorty_dev
@etorty_dev 3 года назад
Who's here in 2021? ...lol Awesome video as always, Kevin!
@thelanguagecube9009
@thelanguagecube9009 2 года назад
Thank you so much for the advice Kevin , i will use this in my next project
@nswayze2218
@nswayze2218 2 года назад
This is such a short lesson but actually so useful!! thank you!
@wiesawmazurak4007
@wiesawmazurak4007 3 года назад
8'30" - nowadays clamp() does this job
@siddiqueath
@siddiqueath 2 года назад
Do this video again plz because its volume is not good and it's gonno long years
@joshuaoseiawuah1157
@joshuaoseiawuah1157 2 года назад
in one of your videos, you recommended we use rem for font sizes so i got confused when i saw you using em
@danielchibuogwu9832
@danielchibuogwu9832 2 года назад
Thank you so much for this video, God Bless you man.
@victordima5259
@victordima5259 3 года назад
That's exactley what i needed! Thank you very much
@rskesavbhaskar5283
@rskesavbhaskar5283 2 года назад
which platfirm you are using can u tell please.......
@mohamedramibenaouf3401
@mohamedramibenaouf3401 Год назад
thank you for this very to understand explanation!
@the_kickers_of_the_coconut6375
@the_kickers_of_the_coconut6375 4 года назад
as always: great tutorial :D
@horacinis
@horacinis 3 года назад
CSS, I hate you CSS lol great video though, thank you!
@TheCocoaDaddy
@TheCocoaDaddy 3 года назад
Thanks for yet another very useful video!!!!
@abigroman
@abigroman 5 лет назад
Hey Kevin I had crank up the volume to hear you. :)
@KevinPowell
@KevinPowell 5 лет назад
Sorry, had some volume issues in older videos. I think it's mostly been resolved, but audio is still a black art for me!
@abigroman
@abigroman 5 лет назад
Kevin Powell - I should have looked at date.
@TazExprez
@TazExprez 2 года назад
Thanks a lot for this! Finally got vmin and vmax.
@dot1160
@dot1160 2 года назад
Thanks Kevin your videos contain very good tips
@markrobbins6985
@markrobbins6985 2 года назад
Thanks Kevin. I was wondering why did you import your fonts in CSS rather than linking them in HTML?
@KevinPowell
@KevinPowell 2 года назад
Going to say it was easier for a demo? Lol. Not good practice, should be in the html, or even better, hosted yourself
@twoplustwoequals5733
@twoplustwoequals5733 Год назад
lol why using it if it can be unpredictable?
@torstenschitkowski23
@torstenschitkowski23 Год назад
Thanks for all your work!
@KevinPowell
@KevinPowell Год назад
Thanks so much!
@mrgiagar3116
@mrgiagar3116 5 лет назад
Hi, thank you very much for the video, it was very useful! If you like, you could make a video with real examples about when to use em/rem instead of vmin/vh/... or instead of % (a sort of "rule of thumb" video for all the css units). That would be even more awesome! :-)
@KevinPowell
@KevinPowell 5 лет назад
I've added it to my list :D
@mrgiagar3116
@mrgiagar3116 5 лет назад
@@KevinPowell Thank you, looking forward to it! :-)
@christinemoore1509
@christinemoore1509 3 года назад
Your video is still helpful. Thanks.
@ozodbekjuraev9268
@ozodbekjuraev9268 3 года назад
Thank you, very useful information
@GGGGGGGGGG96
@GGGGGGGGGG96 3 года назад
It would be nice, if css would allow to use "min-" and "max-" for all css-properties, which are made for sizing. For example: font-size: 8vw; max-font-size: 50px; min-font-size: 12px; - this would solve the problem for media-queries on minute 9:54. It would be possible to define a "min-padding" in combination with "em", and so on.
@Crossnake
@Crossnake 2 года назад
Thank you very much for these videos.
@francosalina9373
@francosalina9373 3 года назад
Amazing tips but the volume its so low :c
@DuyenNguyen-lz3gq
@DuyenNguyen-lz3gq 2 года назад
Character In the video It's great, I like it a lot $$
@LokiDaFerret
@LokiDaFerret 3 года назад
I would say this.... Code maintainability, readability and predictability are important. Which means your use cases are good for example but not terribly practical.
@nikolaikulikov8858
@nikolaikulikov8858 4 года назад
1:06 ...and then... retribution had come 5:30 )) funny)) Anyway)) Thaks Kelvin for the clear explanation, the best what I found so far!)
@KelseyThornton
@KelseyThornton 3 года назад
vmin for headers looks pretty neat!
@conansredbowtie
@conansredbowtie 3 года назад
Thank you that was very helpful.
@rebelshadowrm
@rebelshadowrm 3 года назад
I'm relatively new to css (1.5years in), I noticed that you mentioned media queries for smaller sizes. I've been using calcs i.e calc(.5rem + 1.5vmin) or something like that, is there a potential issue I could run into doing it that way? I've done testing, but I can never be completely sure of everything.
@davidoluremi1981
@davidoluremi1981 2 года назад
Hey Nice Video, you really explained the css viewport concepts. Thanks Kevin.
@SamCrowetheCreativeCrowe
@SamCrowetheCreativeCrowe 2 года назад
Nice explanation per usual. Feeling calmer about front end stuff and warming up to CSS. You may have saved my work from home job with your content. You are making a big difference, Kevin. Thank you!
@paulinadoki1043
@paulinadoki1043 4 года назад
Thank you for your videos and the super cool Responsive Layouts Challange I'm conquering right now. I've started understanding and doing things rather than just being curious about web development.
@devincox7985
@devincox7985 4 года назад
Hey Kevin. Just wanted to say thanks for giving me a half a dozen "monkey-touch-rock" realization moments in the last few days with regards to responsive design. It's helped immensely.
@SquaredbyX
@SquaredbyX 3 года назад
Just wondering, words are kept together or sets of characters separated by whitespace in the html when resizing the viewport? And is there a way to lock/group block level elements, say in an inline-block display, to do the same?
@chanm01
@chanm01 4 года назад
You can use v-units to size text?? My mind is actually being blown right now. It seems so obvious in retrospect. 😅 This responsive design stuff is so cool.
@PaulNieman
@PaulNieman 2 года назад
I've subscribed to the course which is brilliant and in small enough bites to be digestible. There is so much to play with regarding this particular lesson: vh vw vmin vmax. Thank you Kevin.
@jefferymuter4659
@jefferymuter4659 5 лет назад
This one was hyper useful. Just getting into Javascript, but wanted to get a better foundation in HTML&CSS, especially using better mediaQ, which eventually led me here so I can figure out calc(). This was super helpful, and will hopefully help improve my design game quite a bit.
@fridgulum4690
@fridgulum4690 4 года назад
Thank you for the explanation, however, vmax and vmin were a bit unclear to me. I guess, it has to do with padding issue that you faced while explaining the matter.
@matchflixCH
@matchflixCH Год назад
I liked the introduction into the units used for titles. Bringing in min(), max() and clamp() would be a useful addition to it I think.
@maulikpatel7501
@maulikpatel7501 Год назад
thanks for giving us this content..
@rezarahman1782
@rezarahman1782 4 года назад
I know i'm three year late. But better late than never. Can you make a video on "div height and width 100%"?
@diegoperegrino8152
@diegoperegrino8152 Год назад
Thanks for the explanation! Some relative units like these ones can be a little bit confusing for beginners like me.
@matthewcain8118
@matthewcain8118 3 года назад
I honestly thought I'd never have a use for vmin vmax, what a fun surprise! Thanks!
@felixgrdn6729
@felixgrdn6729 3 года назад
Iliterally made a js script for responsive images and yt throw me this. At least i learned something.
@geralddarkobekoe
@geralddarkobekoe 5 лет назад
Thanks,that was helpful
@VJ_7137
@VJ_7137 3 года назад
Nice one 👍 more volume would help🙏
@СерёгаСТАЛКЕР-х7в
@СерёгаСТАЛКЕР-х7в 3 года назад
Hi Kevin, very competent and understandable! Thanks!
@darshaim
@darshaim 6 лет назад
very low audio! !! please fix this
@KevinPowell
@KevinPowell 6 лет назад
I can't do much with this video, but it should be better in my others
@vahan-sahakyan
@vahan-sahakyan 2 года назад
I always try to find ways to avoid Bootstrap and really to keep it as simple as possible, these videos help a lot *thnx*
Далее
The problems with viewport units
13:23
Просмотров 362 тыс.
CSS em and rem explained #CSS #responsive
16:54
Просмотров 386 тыс.
ХОККЕЙНАЯ КЛЮШКА ИЗ БУДУЩЕГО?
00:29
🛑самое главное в жизни!
00:11
Просмотров 35 тыс.
Teeth gadget every dentist should have 😬
00:20
Просмотров 941 тыс.
Flexbox design patterns you can use in your projects
15:33
5 simple tips to making responsive layouts the easy way
15:54
CSS Tips And Tricks I Wish I Knew Before
12:12
Просмотров 480 тыс.
The secret to mastering CSS layouts
17:11
Просмотров 283 тыс.
Please stop using px for font-size.
15:18
Просмотров 171 тыс.
Are you using the right CSS units?
6:30
Просмотров 456 тыс.
Use these instead of vh
6:06
Просмотров 510 тыс.
A Full Guide to CSS UNITS!
13:38
Просмотров 16 тыс.