Position absolute and responsive layouts

  Рет қаралды 91,732

Kevin Powell

Kevin Powell

Күн бұрын

🎓 - I have a free course on conquering responsive layouts: courses.kevinpowell.co/conque...
A lot of people struggle with responsive layouts, and even more so when they use position: absolute. In this video I'm looking at how we can work with position absolute in a responsive way 🙂.
🔗 Links
✅ The Frontend Mentor project: www.frontendmentor.io/challen...
✅ My Code: github.com/kevin-powell/fem-c...
⌚ Timestamps
00:00 - Introduction
01:35 - The HTML
03:12 - Setting things up the right way to use position absolute
05:47 - Why you need a defined space for your positioned elements
07:40 - Positioning in relation to the element’s containing block
12:50 - Emulating padding with position absolute
18:17 - Applying this to larger layout pieces
#css
--
Come hang out with other dev's in my Discord Community
💬 / discord
Keep up to date with everything I'm up to
✉ www.kevinpowell.co/newsletter
Come hang out with me live every Monday on Twitch!
📺 / kevinpowellcss
---
Help support my channel
👨‍🎓 Get a course: www.kevinpowell.co/courses
👕 Buy a shirt: teespring.com/stores/making-t...
💖 Support me on Patreon: / kevinpowell
---
My editor: VS Code - code.visualstudio.com/
---
I'm on some other places on the internet too!
If you'd like a behind the scenes and previews of what's coming up on my KZbin channel, make sure to follow me on Instagram and Twitter.
Twitter: / kevinjpowell
Codepen: codepen.io/kevinpowell/
Github: github.com/kevin-powell
---
And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!

Пікірлер: 152
@Username-em1oe
@Username-em1oe 11 ай бұрын
I just want to say that you are the best educator on CSS. You have given me the ability to understand CSS at a much deeper level. Keep doing what you're doing. It is very much appreciated. Thanks Kevin
@clevermissfox
@clevermissfox 10 ай бұрын
Seconded! Probably more like 70 thousanth-ed
@daveturnbull7221
@daveturnbull7221 Жыл бұрын
I need to start taking serious notes from your videos. You keep giving us so much info that a lot of it is getting lost in the mess I like to call my brain. Life was so much easier before finding your channel and getting exposed to just how powerfull CSS actually is (not just for setting colours etc). Anyway, I'm off to put in a bulk order for notepads...
@KevinPowell
@KevinPowell Жыл бұрын
Like Super Mario said, something like Notion might be perfect (it can seem overwhelming because it's so customizable, but there are starter templates for note taking and stuff). It's really handy. I do think written notes are useful too, and I think writing by hand and scribbling out drawings and stuff has a lot of benefits, but being able to quicky reference stuff is always great.
@outpost31737
@outpost31737 Жыл бұрын
Create a folder on your PC/MAC call it something like 'My Webkit' and add your snippets there for easy reference. Works for me :)
@cekuhnen
@cekuhnen 11 ай бұрын
The nice thing is he comes from print and gets the confusion…
@ob5804
@ob5804 9 ай бұрын
​@@KevinPowellKevin, hello. I have a problem with slider's arrows. When arrows are next to each other, but positioned absolutely, along the container, and when the window is narrowed, the arrows move to the center (Can this approach solve that?
@TheMsWrong
@TheMsWrong Жыл бұрын
I used to absolutely dread any time I had to work with position: absolute but you really helped me understand it much better!
@leolecee9405
@leolecee9405 Жыл бұрын
Just as clear, synthetic and practical, as usual 🤓 And as I'm just tackling my first form / form-validation project, it would be awesome to see your approach to that kind of things. Thanks again for everything you're doing 👌
@mikefernandez403
@mikefernandez403 Жыл бұрын
Thank you very much Kevin, I was kind of stuck trying to create a brackground-img for this exercise and you solved all my problems x) I learned so much from your tutorials. Thanks for making people love CSS !
@greentea2430
@greentea2430 Жыл бұрын
Hi, Kevin! Just wanted to say that your style of teaching and explaining stuff is absolutely brilliant, I've been with the channel for 3 months and never missed a single video. It helps me a lot in fighting my anxiety, so thank you very much ; - ). It would be wonderful if you could deep dive into the forms in one of the future videos, particularly into the js side of things. It is always so confusing to get forms nice looking and perfectly working, so yeah.
@StopLossDill
@StopLossDill Жыл бұрын
Thank you for this. You have helped me more than you could imagine. All my responsiveness-related bugs are instantly fixed after watching this video. This overlapping card concept is so cool. Thanks for years of great content man.
@clevermissfox
@clevermissfox 9 ай бұрын
I had no idea you could set up your child elements like the name and card number to absolute, and THEN give that parent a positon absolute too. Obvisouly there are specific use cases this would be applied and i try to avoid it but i just assumed if you took off relative from the parent everything would break. This channel is amazing. So generous
@daniru2505
@daniru2505 Жыл бұрын
Awesome video. I currently have a project requested by my father. I encountered a problem about layouts and your CSS grid tutorial from a year ago helped me. I still have a page to do that will deal with position absolute and this came in clutch.
@iwannabekoshka
@iwannabekoshka Жыл бұрын
I did not know that you can use "position: absolute" and arrange elements relative to it, always did one more wrapper with "position: relative"... Thank so much, you made my life easier
@BallEcomThatthana
@BallEcomThatthana 10 ай бұрын
Thank you Kevin as always great content
@stephanechataignie
@stephanechataignie Жыл бұрын
Great tutorial as usual. A full serie for doing a great form with its validation will be great
@dre429
@dre429 Жыл бұрын
Thank you so much this has helped me a lot with one of my projects and even the small off-topic note was very helpful to me and taught me something. Thank you for such quality teaching!
@oliverstbng6329
@oliverstbng6329 Жыл бұрын
I thought i was already in love with css, but since i discovered your channel i know what it means to really be in love with css. You do a great job and inspire me. Greetings from germany.
@AJ-1404
@AJ-1404 Жыл бұрын
Just when I needed this for a project! Thank you Kevin :)
@pravinkori3381
@pravinkori3381 Жыл бұрын
Really amazing and very insightful. Been watching your videos and it really has made me fall madly in love with CSS. I'd really love to have another video on creating form.
@bobdinitto
@bobdinitto Жыл бұрын
Very interesting and thought provoking. Thanks, Kevin. CSS positioning always seems like Alchemy to me. But I'm slowly starting to wrap my head around it.
@lorenainfanter.3099
@lorenainfanter.3099 Жыл бұрын
I'm learning a lot with every video you post! Thank you very much!!
@moroccowave
@moroccowave Жыл бұрын
I like the way you explain things. You are really helpful. Thanks Kevin :)
@rvoitiv
@rvoitiv 11 ай бұрын
Learning something new from each of your videos. Though the video itself is about position absolute, that “margin-left:auto” trick was really neat. Thanks Kevin!
@dennisllopis2478
@dennisllopis2478 Жыл бұрын
Amazing content. Thank you Kevin!
@deanlane
@deanlane Жыл бұрын
Thanks, Great guide. It's funny, just as I am working on a similar problem on my projects you come along and put out a new guide solving the issues I'm having lol. Thanks
@WilledWest
@WilledWest Жыл бұрын
woooooooww, I just the opened the youtube app on my phone basically to check out tutorials on how people went about working on this card project particularly , not knowing Kevin had worked on it already and has posted it, and I've been on youtube a few times since yesterday, but didn't see this, today that I wanted to search out the problem, kevin's video was the first on my youtube, haven't even searched it already. if this is a sign for me not to give up on coding , I'll think about it. lol, thanks Kev❤
@vimvexvimvex8780
@vimvexvimvex8780 Жыл бұрын
Perfect! Many thanks!
@ntwalimudasubiragustave7343
@ntwalimudasubiragustave7343 9 ай бұрын
So helpful man... The problem was just solved before finishing the video
@jorgegamboa5408
@jorgegamboa5408 Жыл бұрын
awesome kevin, i have learned a lot from this channel.
@rodglennrojas3067
@rodglennrojas3067 Жыл бұрын
I immediately liked and subscribed your channel, it works like magic. thank you.
@arifulhaque3236
@arifulhaque3236 Жыл бұрын
Thanks a lot sir...can't control myself to thank you for everything in comment section.
@NiceChange
@NiceChange Жыл бұрын
Love this. Solved so many issues.
@LuxKG
@LuxKG Жыл бұрын
As a teacher on different field (insert "c'mon guys, it's not a music theory" meme here 😆 ), I have to say that you nailed it with explanation! Outstanding job! Cristal clear. Thank you for all those tutorials!
@Technoph1le
@Technoph1le Жыл бұрын
21:00 Didn't know that `position: absolute` would act as relative to its absolute positioned children. 👍
@dave6012
@dave6012 Жыл бұрын
Yeah, that was a serious departure from my understanding, but lady CSS is actually on our side with that one 🤷
@sickysore
@sickysore 11 ай бұрын
I appreciate this video so much, thank you kind person! Very useful and easy to follow.
@kirby6362
@kirby6362 Жыл бұрын
Today I realized that, after watching ~100 Kevin Powell videos, his opening is not “Hello my friend and friends”. 😂 I always thought it was so cute and personalized that he would greet me as his friend lol
@davidcbeaudoin
@davidcbeaudoin Жыл бұрын
Ah yes, absolute positioning... my old arch nemesis. Lots of good stuff in here though that I wasn't aware of. I've been out of the CSS game for a while, only recently dove back in while updating a site I coded years ago. Thanks for the great lesson/overview.
@wahyusa
@wahyusa Жыл бұрын
Thank you ! I've got lot of new insights
@stepheninnocent9540
@stepheninnocent9540 Жыл бұрын
I have learned so much from u I can now arrange my flex box very well
@justsaybobby
@justsaybobby Жыл бұрын
Yes let's look at that in the future.
@daveskye
@daveskye Жыл бұрын
Please more on forms! I use them a lot in projects and having some fresh ideas would be helpful.
@VVigneshwaranMSEC
@VVigneshwaranMSEC Жыл бұрын
Actually I am doing project and really stuck in position property and correct time it's help me. Thank you man✨
@SidBarnhoorn
@SidBarnhoorn Жыл бұрын
This was great and very helpful! Thank you! :)
@ruthy08
@ruthy08 8 ай бұрын
6:54 - this is the epitome of the meme. "Why does that not work." I love that you left that in.
@frankroos1167
@frankroos1167 Жыл бұрын
Everything is related to the parent element...except font-size. That's still in rem. With container, that can be done too. I tried it before. It allows us to change the size of the parent element without breaking the layout. Useful to make it a "module" type thing that can change nicely when the designer desides it has to go differently. Admitted, that has nothing to do with the subject, position absolute. But it is a nice addition when it comes to the responsive aspect.
@proteus1
@proteus1 Жыл бұрын
Another quality demo from Front Ender Mentor. CSS is the Web.
@phucnguyen0110
@phucnguyen0110 Жыл бұрын
Another legendary project from Frontend Mentor, haha xD
@malamhari_
@malamhari_ Жыл бұрын
It's gonna be cool and very informative if we can continue finish this project sir
@david1801
@david1801 Жыл бұрын
I was just struggling the whole day keeping the cards in place. Thanks
@zakieed9554
@zakieed9554 Жыл бұрын
this is the best css chanel for peoples whos english is the second language 🤍
@md.ataurrahmansharif5305
@md.ataurrahmansharif5305 Жыл бұрын
Thank You very much
@0xtz_
@0xtz_ Жыл бұрын
I hade this problem just last night 😂😂😂 👌🏼 man u fixed the problem
@dragonnexs3621
@dragonnexs3621 Жыл бұрын
Kevin, I like the fact that some of your video are made to help young developers learn more about the css, but you still end up including some obscure properties without explaining too much about it because it is not the purpose of the video. I consider myself good at css but I clicked the video just in case I'm missing on something and I ended up learning about the "revert" value that you used on the max-width. Your videos never disappoint me, good job and ty for your work! 👍
@exsitewebsolution6803
@exsitewebsolution6803 Жыл бұрын
Absolutely brilliant! Please please PLEASE make a video for a responsive CHAT UI
@christopherbarber7705
@christopherbarber7705 Жыл бұрын
thank you again sensei
@kylevandeusen
@kylevandeusen Жыл бұрын
Epic tutorial!
@dougphillips5686
@dougphillips5686 Жыл бұрын
Great info.
@catherinegreen7454
@catherinegreen7454 Жыл бұрын
Love the DFTBA top!
@clevermissfox
@clevermissfox 8 ай бұрын
I’d be interested in a video looking at revert and initial and their differences ❤
@sovereignlivingsoul
@sovereignlivingsoul Жыл бұрын
positionng is such a tiresome process sometimes, great video Kevin, on the question of forms, i have been looking into the proper uses for aria with my code, forms can be improved with aria, so maybe do something on when to use aria in forms
@sas3021
@sas3021 7 ай бұрын
thank you
@marcorosenbaum9900
@marcorosenbaum9900 2 ай бұрын
Nice!
@michalnowak2181
@michalnowak2181 Жыл бұрын
thx kevin :)
@Paulo280713
@Paulo280713 Жыл бұрын
great content
@kevinfisher7032
@kevinfisher7032 Жыл бұрын
As always, an excellent demo. In my experience after hours of trying to get "position:absolute" to work (we’ll gloss over the swearing and hair pulling) the solution usually comes down to one question-Have you set or where are you setting position:relative? These days that’s usually the first thing I think about if I’m gonna be using absolutely positioned divs.
@sukumizune2477
@sukumizune2477 Жыл бұрын
Great tutorial as always. What would you recommend if you needed the positioned elements to scale with the container?
@Udaykumar-rt5di
@Udaykumar-rt5di Жыл бұрын
Hey @Kevin Powell your videos are really and really informative. Can you make a video on how should one code thier web app for thier company or bringing it live for other users to use. I heared some stuff like dependenies from my friends but didn't unerstand much about it.
@lesnaSvalka
@lesnaSvalka Жыл бұрын
23:51 Kev, be careful with the glasses, man. 😆Love your videos, keeup it up!
@handsome_man69
@handsome_man69 Жыл бұрын
Love love love
@onlyzach1
@onlyzach1 Жыл бұрын
Great video as always! Would love to see a full build out video with doing the background on it as well. Any reason you used 960px on the media query? Thought you were only using rem for the most part now.
@KevinPowell
@KevinPowell Жыл бұрын
Fort the media query, I just threw something on there, I sometimes use pixels in more beginner friendly videos to avoid having to talk about it, lol. Using anything other than pixels becomes a sticking point for some, and for media queries, it doesn't make a difference really. The one unit that is the most consistent in media queries is em though, because of a strange zoom thing in Safari, but it's a very small detail
@enigma2303
@enigma2303 Жыл бұрын
Yes I need this so much tomorrow is the freakin deadline of our project.... 😭
@KevinPowell
@KevinPowell Жыл бұрын
Good luck!
@justsaybobby
@justsaybobby Жыл бұрын
YES!
@eggsforbacon
@eggsforbacon Жыл бұрын
Seriously dog where do you have the microphones. This is super useful right now, thank you!
@thevishalvadher
@thevishalvadher Жыл бұрын
Hello Kevin Sir i watched most of your videos and learn lots of things about css and html BIG THANK YOU for that i have 1 request for you can you make video for responsive website with HTML & SCSS please i want to know how to organize scss files on real world websites. thank you;
@Sarm8
@Sarm8 Жыл бұрын
Wonderful tutorial! Super informative. Quick question, is there any reason not to put all the elements inside the card image rather than in a parent container?
@muisadinam9615
@muisadinam9615 7 ай бұрын
I was just wondering about the same question 👍 Maybe @KevinPowell can answer this one? 🙏
@xiggywiggs
@xiggywiggs Жыл бұрын
please please please do a video on forms and validation!!!
@oreki1996
@oreki1996 Жыл бұрын
Can you make a tutorial on How to be a genius like Kevin Powell next?
@AntonioBenderas
@AntonioBenderas Жыл бұрын
@Kevin Powell please make a video what is the difference between % vs. em font-size
@KevinPowell
@KevinPowell Жыл бұрын
When used for font-size, they're basically the same thing. 1em = 100%, 1.25em = 125%, etc.
@lalit-singh-bisht
@lalit-singh-bisht 11 ай бұрын
you are on a whole another level...I just can't keep up with you
@aoussabah
@aoussabah Жыл бұрын
Thank you for this very valuable video! I have one question though, in 10:16. doesn't CSS rule with (max-width: revert) override the (max-width: 100%) rule for elements of .card-front_bg?
Жыл бұрын
that was very helpful. although I would use background color instead of border or outline color. that way it would not add the border size to the box.
@KevinPowell
@KevinPowell Жыл бұрын
You can also use outline, just like border but with no actual impact on the size ☺️
@JosBlomsma
@JosBlomsma Жыл бұрын
'Magic numbery' 🥰
@justinanderson267
@justinanderson267 Жыл бұрын
You may be able to avoid the "magic number" in the CVV section by doing bottom: 50% instead of top:44%
@NorthTonawanda1
@NorthTonawanda1 Жыл бұрын
There's 3 ways to learn these tricks: (1) Watch the video all the way through (never works.) (2) Watch all the way through, pausing, rewinding, focusing incessantly and spending 3x longer than step one (this kind of works, but not really.) (3) Roll up your sleeves and play along (this works, but you still need to pay close attention.) I need to get better at step 3.
@LordBecher
@LordBecher Жыл бұрын
Hey Kevin, well done explanations, but could you do me a favor? Surprisingly many people have sight impairments, very often issues with differentiating red and green, could you try to replace one of them in your borders? You are such an educated, helpful person, but I struggle a bit with the visuals sometimes :)
@KevinPowell
@KevinPowell Жыл бұрын
For sure! I try to go with high-contrast colors compared to my backgrounds, but never really took that into accouotn when I should have. Correct me if I'm wrong, but if I avoid reds/pinks/oranges as a rough rule of thumb, it should be alright?
@LordBecher
@LordBecher Жыл бұрын
@@KevinPowell I am not that knowledgeable, but I know that red-green color deficiency is by far the most common, 10% of men and 1% of women are affected. In these cases not contrasting red and green is enough already, in more rare forms like color blindness (mono/dichromacy) you'd probably try to use colors with very different hue or saturation, full color blind (achromatic) people can only differentiate the value of the color.
@joshuakirby6952
@joshuakirby6952 Жыл бұрын
If you have heavy elements (i.e., complex svgs or filters), would "transform()" be better for performance?
@fabianmichael9457
@fabianmichael9457 Жыл бұрын
An alternative to using img tags is using aspect-ratio
@KevinPowell
@KevinPowell Жыл бұрын
100% :)
@codeme8016
@codeme8016 Жыл бұрын
Wondering why not using Flex to locate some of the items?
@androidetube
@androidetube Жыл бұрын
what is the reason for "min-block-size: 100vh;" on ".content-grid" ?
@allan_archie
@allan_archie Жыл бұрын
How did you do the dark mode toggle?
@arnavsshah
@arnavsshah Жыл бұрын
GOD!
@Tony.Nguyen137
@Tony.Nguyen137 Жыл бұрын
Hi. Can you make a video about the css property contain? Apparently this css property improves the performance of a website but I don’t understand the documentation :-(
@KevinPowell
@KevinPowell Жыл бұрын
I was using it today and thought to myself I should make a tutorial on it 😂 It can improve performance in specific situations, but it's a little niche so I wouldn't worry too much about it
@saaika5922
@saaika5922 Жыл бұрын
From where are you getting those projects? I would like to do some designed, instead of designing everything on my own.
@simoncallelaverde
@simoncallelaverde Жыл бұрын
Please read my other comment on "background-images" vs "imgs", and the why.
@waleedsharif618
@waleedsharif618 Жыл бұрын
What do you think of tailwind ? I just started to learn it and html looks too messy with tailwind
@KevinPowell
@KevinPowell Жыл бұрын
I'm not the biggest fan in the world :D
@USPSLaura
@USPSLaura Жыл бұрын
why do you prefer to use unit rem or em instead of px
@outpost31737
@outpost31737 Жыл бұрын
The funny thing about websites is that they're responsive by default it's only when we apply our styles that problems occur!
@KevinPowell
@KevinPowell Жыл бұрын
100%
@OCEMTechZone
@OCEMTechZone 7 күн бұрын
🎉
@justinkelley111
@justinkelley111 Жыл бұрын
I was told that whwen you go to put a website up, they won't be visible to search engines. I guess we have to insert something into our code, I was told that this was a local plus link? How do we do that?
@nomadshiba
@nomadshiba Жыл бұрын
tbh as you said grid would have been a lot less painful for something like this can make this responsive too without using @media EDIT: also you can move the card number to center using left: 50%; transform: translateX(-50%);
@RealCaptainAwesome
@RealCaptainAwesome Жыл бұрын
How do you handle a main-content element being < the height of the window? I have found min-height: 100vh is that okay? I focus on backend development, so css wizardry is confusing and scary
@KevinPowell
@KevinPowell Жыл бұрын
Ideally, min-height: 100dvh, which will adapt to the mobile UI elements that move in/out, but browser support isn't amazing yet, so 100vh is fine for now, unless you run into an issue on mobile that might take a little mucking around to fix
@RealCaptainAwesome
@RealCaptainAwesome Жыл бұрын
@@KevinPowell thanks. I remember why WordPress was so frustrating back in the day now.
@coecemalomijebolje
@coecemalomijebolje 3 ай бұрын
😊
@TheOKest
@TheOKest Жыл бұрын
Question from a new learner, why code all the informaion on the card if you could just upload an img with the credit card information and logo already on it?
@KevinPowell
@KevinPowell Жыл бұрын
Part of this challenge (where I had the "form goes here"), is to make the credit card information update as it's typed into the form, so to do that, it needs to be code :)
A practical guide to responsive web design
23:13
Kevin Powell
Рет қаралды 181 М.
Avoid These 5 Awful CSS Mistakes
20:42
Kevin Powell
Рет қаралды 191 М.
Каха заблудился в горах
00:57
К-Media
Рет қаралды 9 МЛН
Mama vs Son vs Daddy 😭🤣
00:13
DADDYSON SHOW
Рет қаралды 46 МЛН
Я обещал подарить ему самокат!
01:00
Vlad Samokatchik
Рет қаралды 8 МЛН
How Many Balloons Does It Take To Fly?
00:18
MrBeast
Рет қаралды 199 МЛН
min(), max(), and clamp() are CSS magic!
18:12
Kevin Powell
Рет қаралды 293 М.
5 super useful CSS properties that don't get enough attention
16:23
Kevin Powell
Рет қаралды 143 М.
Container Queries are going to change how we make layouts
24:24
Kevin Powell
Рет қаралды 172 М.
Learn CSS Positioning Quickly With A Real World Example
8:32
Slaying The Dragon
Рет қаралды 623 М.
Avoid these 5 beginner CSS mistakes
21:38
Kevin Powell
Рет қаралды 79 М.
CSS Anchor Is The Best New CSS Feature Since Flexbox
15:39
Web Dev Simplified
Рет қаралды 363 М.
The problems with viewport units
13:23
Kevin Powell
Рет қаралды 357 М.
These CSS PRO Tips & Tricks Will Blow Your Mind!
8:48
Coding2GO
Рет қаралды 158 М.
Relative colors make so many things easier!
13:16
Kevin Powell
Рет қаралды 42 М.
CSS Tips And Tricks I Wish I Knew Before
12:12
Lama Dev
Рет қаралды 456 М.
Каха заблудился в горах
00:57
К-Media
Рет қаралды 9 МЛН