Using CSS Position Absolute: some practical examples

Поділитися
Вставка
  • Опубліковано 2 лис 2024

КОМЕНТАРІ • 157

  • @trainerkellysnetwork
    @trainerkellysnetwork 3 роки тому +3

    I know this video is old, but I want to say THANK YOU! I struggled for hours trying to figure out how to align a button inside of a DIV element that was still responsive and I could not figure out how to do it. Google wasn't really showing me anything that was helpful. All it took was watching this video and being reminded that the parent element (in this case, my DIV) needed positioning itself. 😭 Thank you SO much for making this very clear tutorial! Thank you, thank you, THANK YOU!!!

  • @ganeastefan4287
    @ganeastefan4287 4 роки тому +38

    Just wanted to say @kevin powell I've been browsing through your channel for the past few days, spending a few hours at a time and your content is so good I just don't even know where to start and where to keep going, sometimes. Thanks for your amazing work, it helps a ton!

    • @KevinPowell
      @KevinPowell  4 роки тому +6

      Glad that you're enjoying my content! 😊

  • @eddykagia4212
    @eddykagia4212 3 роки тому +6

    This blew my mind. So subtle yet so effective

  • @darshanpandya1087
    @darshanpandya1087 Рік тому

    thank you kevin for all the amazing videos you share , i try to watch as soon as i got notified and try to use on my projects too.

  • @seanpheneger6632
    @seanpheneger6632 6 років тому +63

    Kevin, you know in Emmett you can type loremX (where x is the number of words you want it to generate) i.e. lorem10 and then tab and emmett will auto generate 10 lorem words instead of saving lorem bits on a different doc to cut and paste.
    p.s. love the content. always learn something new every video you put out

    • @KevinPowell
      @KevinPowell  6 років тому +15

      It never EVER works for me, it always gives me a tag instead! I've used it in Atom, VS Code and Codepen and I wish it would work SOOO much, haha. I think I had it work once, and I don't know what I did!

    • @ShotgunChoda
      @ShotgunChoda 6 років тому +17

      Don't know if you just made a typo here, but it's lorEm, not lorUm, maybe that's what's tripping you up.

    • @barelyviable5004
      @barelyviable5004 6 років тому +5

      also it doesn't work when Capitalized, it has to lowercase, sometimes I mess up there =p

    • @wshah5761
      @wshah5761 6 років тому +2

      type lorem5 and press tab, it should work :-D, I also struggled with it before

    • @aditnetral
      @aditnetral 5 років тому

      @@KevinPowell wow

  • @nickbrown6754
    @nickbrown6754 3 роки тому

    I've been struggling all day with the positioning of a responsive video that was suppose to be about 1/3 of the screen wide and sit above the fold in the bottom right on all screen sizes above 992px wide.
    After watching this video the solution seems so obvious and I can't believe I was being so thick. Thank you for kicking my brain back into gear 🤘

  • @nlorens
    @nlorens 2 роки тому +4

    Thank you Kevin for explaining the logic behind every step, it is super helpful to understand the concept. I really enjoyed trying out this fun project :)

  • @yetanotherusername12
    @yetanotherusername12 6 років тому

    Your videos always clear up whatever impossible mess I've created in my code as I stumble through learning web coding. Thanks!

    • @KevinPowell
      @KevinPowell  6 років тому

      Haha, glad I'm able to help out a little :)

  • @sage5296
    @sage5296 3 роки тому +2

    The content on this channel is great, I'm learning CSS on my own as I'm working through CSSBattles, and this is a really nice way to augment that while also learning the proper way to do things to balance out any bad habits I'm forming with CSSBattles!

  • @A_Lesser_Man
    @A_Lesser_Man 5 років тому +5

    that looked great! yes, you could DRY it up a bit. and i had no idea you could do THAT to a shadow! wow. neat.

  • @sivaganesh4489
    @sivaganesh4489 Рік тому

    Kevin, GOAT of css

  • @miguelbm1989
    @miguelbm1989 2 роки тому

    I had to do an AB testing for my work. This video helped me finish it :) thank you so much

  • @matthewashworth4992
    @matthewashworth4992 4 роки тому

    Thank you K-Pow love your videos, they make my corner of the web nicer, You are a star!

  • @Devendrakr63
    @Devendrakr63 3 роки тому +1

    He is King of CSS.

  • @nizamuddinshaikh3185
    @nizamuddinshaikh3185 5 років тому +1

    Topic excellently explained! Now, I am clear about position : absolute. Thank you, KP. 😃

  • @TheElkster
    @TheElkster 4 роки тому

    Really loved the use of z-index and creating layers - losing luminosity with other elements having an rgba background has always stumped me - but this now explains how to avoid it! Thanks Kevin! :)

  • @westfield90
    @westfield90 5 років тому

    Thank you. Nothing like real world examples to explain this stuff.

  • @Seantf12345
    @Seantf12345 4 роки тому +1

    Awesome showcase of the absolute position! Thanks for this a real inspiration!

  • @chinmaykumar7975
    @chinmaykumar7975 4 роки тому

    You made everything so much easy and clear . Thank you very much.

  • @sumitsahu2338
    @sumitsahu2338 Місяць тому

    Amazing content and teaching.

  • @esraamohamed5601
    @esraamohamed5601 2 роки тому

    Thank you so much for all you have done!

  • @whatsaguygottado2669
    @whatsaguygottado2669 5 років тому +1

    Interesting video! Gave me all kinds of things to think about w/ positioning. Keep-up the good work!

  • @DavidWyatt
    @DavidWyatt 6 років тому

    Excellent, as always! A great follow-up video would be writing the CSS that would allow this to degrade gracefully at mobile breakpoints. That's probably where most of us have the most problems.

    • @DavidWyatt
      @DavidWyatt 6 років тому

      I forked your original pen and added a breakpoint. Because your original CSS was so clean, it only took a few lines of code to make this card look great on mobile. Take a look at the modified pen codepen.io/designoneweb/pen/jKZbzW and let me know what you think. Keep up the great videos!

    • @KevinPowell
      @KevinPowell  6 років тому

      I find it easier to design something more basic as the mobile one, and then add things and make it more complicated for larger screens, instead of stripping stuff away. But yeah, that's a good topic idea, though it does delve into design a lot as well, and making design decisions for different screen sizes.

    • @KevinPowell
      @KevinPowell  6 років тому

      Sorry I hadn't seen the followup comment, UA-cam had flagged it (because it had a link in it, I'm guessing). Really nice stuff, glad you took the time to do that, it looks great :)

  • @rofazayn
    @rofazayn 6 років тому +1

    Thank you Kevin, I love your videos.

    • @KevinPowell
      @KevinPowell  6 років тому

      Not a problem, I'm glad to hear that you like them :D

  • @gilmoretj
    @gilmoretj 5 років тому

    Kevin, I am a big fan of your videos, especially the Five-minute Fridays. One comment regarding CSS positioning: Absolute positioning is not dependent on an ancestor having a position property but on having an ancestor defining a position other than the default of static. Keep up the good work.

  • @thilakamn575
    @thilakamn575 4 роки тому

    Awesome presentation and Thank you

  • @Alessandro-nq3tm
    @Alessandro-nq3tm 5 років тому +3

    Amazing tutorial mate! So useful

  • @ellaamaechi-qk9ol
    @ellaamaechi-qk9ol 7 місяців тому

    i really learnt a lot from this

  • @christinejurewicz3057
    @christinejurewicz3057 6 років тому

    Thanks Kevin, this really clarified some things regarding positioning

    • @KevinPowell
      @KevinPowell  6 років тому

      Awesome, glad it helped Christine :)

  • @GeorgeFlorian12
    @GeorgeFlorian12 6 років тому +3

    Awesome video, man, like always ! As a total beginner I don't know when or where some code will work or not, like you the 'height' example in this video. There are a lot of tricks related to what will work and what will not depending on 'position' or 'display' or who knows what. I think that explaining "the missing link" (for me at least) would make for a great video.
    Or do you already have videos about that ? I haven't seen all of your video, obviously :))

    • @GeorgeFlorian12
      @GeorgeFlorian12 6 років тому +1

      Like, even here, in this video: the 'width' of the parent div is 40% and the 'height' and 'width' of the img are set at 100%,. The img has a 705 width/height, right ? So it's a square. Why did it change its aspect ratio and began looking like a rectangle ?

    • @KevinPowell
      @KevinPowell  6 років тому +2

      Because CSS is really strange, lol. I'd love to make a missing link video, but that would most of CSS, lol. It's one of those things that, the more you use it the more you figure out the subtleties of it. As much as possible I try to get into these subtleties in my videos, but there are sooooo many! It can definitely be frustrating as you are learning, but you'll start figuring it out!

    • @davidmarcos3661
      @davidmarcos3661 5 років тому

      @@KevinPowell I was wondering the same issue about the aspect ratio of the image, I guess i'll have to move on and accept that CSS is strange, lmao

  • @nithinmuniraju4482
    @nithinmuniraju4482 6 років тому

    Even you too awesome. Nice teaching, all your tutorials makes me perfect of some topics. Thank you a lot 👍👍

    • @KevinPowell
      @KevinPowell  6 років тому

      Thanks so much, I'm glad you're enjoying the tuts!

  • @cindykee3719
    @cindykee3719 5 років тому

    Is z-index affected by parent and child positions? Or is it always global to the whole ? I was a little confused by the tweaks you did there.
    I am learning so much about CSS that I didn't know before with your videos. I am a full-stack developer and I have never studied CSS specifically. I just have kind of picked it up along the way. And I know enough that a beginner's CSS course would bore me just to fill in my gaps, so your videos are super-helpful for that gap-filling! And for advanced techniques. Thank you!

  • @luizmelo8611
    @luizmelo8611 5 років тому

    Thank you very much, sir! Your tutorials are awesome and to the point! I wish you the best!

  • @mananwebandall1203
    @mananwebandall1203 5 років тому

    Very cool boss .... Just awesome explanation...👍👍👍

  • @thedacian123
    @thedacian123 3 роки тому

    Can you explain position absolute and overflow hidden of postionated parent,please.?
    I've seen some implemetation of slidders using this one.Thank you!

  • @Rocadamis
    @Rocadamis 3 роки тому

    So, how would you go about putting a shadow behind the yellow banner sticking out on either side? Maybe put a negative z-index box behind each one with a box-shadow?

  • @DuyenPhanLan
    @DuyenPhanLan 2 роки тому

    Great content! Thanks

  • @heidischorlemmer4407
    @heidischorlemmer4407 2 роки тому

    Hi Kevin, what haben I to do to get the sourcecode of your videos? Must I make a subscription ?
    You videos are so great .

  • @asdfghilal
    @asdfghilal Рік тому

    You are the best!

  • @franktielemans6624
    @franktielemans6624 6 років тому +11

    Damn,, this was clever

  • @cannabisanomaly
    @cannabisanomaly Рік тому

    Hey Kevin, thank you SO much for all of your work; you're singlehandedly teaching me how to be a web developer. I noticed something pretty odd when it comes to the 1px solid white border you've done for the card decoration. I'm using chrome and I noticed that when adjusting the browser window, the 1px border seems to sometimes appear not solid. But when adjusting the window some more, it goes in and out from looking to solid to looking like there's some space within the border, almost like it's two parallel lines. Do you have any idea what is causing that?

  • @nargesbayat277
    @nargesbayat277 3 роки тому

    That is great!thank you very much

  • @Fliteska
    @Fliteska 5 років тому

    That was really cool, never thought of using pseudo elements for cutting through an element. The card looks like it could be a digital boarding pass

  • @workingTchr
    @workingTchr 2 роки тому

    I needed a menu type element and all the pre-made code I found was way too complex (trying to be too many things) so I had to make my own. Absolute position is used in all of the menu controls so they can overlap content they drop down over (like a Select). So that's what got me here: menus.

  • @infosandfacts7536
    @infosandfacts7536 4 роки тому

    Awesome stuff. Thanks a lot.

  • @zahidhossainarpo5043
    @zahidhossainarpo5043 3 роки тому

    these are awesome man..thanks a lot

  • @georgesmith3022
    @georgesmith3022 6 років тому +1

    thanks kevin, interesting stuff definitely

  • @Rebbelde
    @Rebbelde 4 роки тому

    Whats the keyboard hot key to autocomplete image tags and how you define width and height in source ? I tried it but it didn't work

  • @michajankowski3615
    @michajankowski3615 6 років тому

    Cool example!

  • @ElNicopewpew
    @ElNicopewpew 6 років тому

    Love your videos, great job !

    • @KevinPowell
      @KevinPowell  6 років тому

      Thanks a lot, glad you liked it :)

  • @boyacosweep
    @boyacosweep 2 роки тому

    Amazing!

  • @joeldcanfield_spinhead
    @joeldcanfield_spinhead 5 років тому

    I love seeing your designer mind at work.
    Re: the shadow on the left end, would it be feasible to add another element behind that bit, and put the box-shadow on that? That's my Photoshop cheat, so I'm curious how you might pull it off here. It'd really finish off the design.

    • @KevinPowell
      @KevinPowell  5 років тому +1

      Really good point. We could add a second shadow onto that ::after element to pull it off :)
      - box-shadow: inset 12px 0 10px -10px rgba(0,0,0,.5), 20px 0 40px rgba(0,0,0,.25);

  • @batucka1
    @batucka1 4 роки тому

    Hi Kevin, great videos, thanks for everything. About this one, I have a question, how I can "activate" the links? I mean, with your example, if I want to put a link to google.com once the user click the image or text, the link doesn't work :( I was looking everywhere but with out any sucess, could you help me please?

  • @ArturBrosig
    @ArturBrosig 3 роки тому

    Awesome. On 10:25 you say that the border is 1px thick, but isn't it actually 2px thick? (1px left and 1px right)

  • @CreativeSequence
    @CreativeSequence 5 років тому

    Great video very helpful

  • @monk333
    @monk333 6 років тому

    Nicely done!

  • @jaimesastre6393
    @jaimesastre6393 6 років тому

    thank you, awesome ! really good explained!

    • @KevinPowell
      @KevinPowell  6 років тому

      Thanks a lot, glad you liked it :)

  • @davidepalombo2141
    @davidepalombo2141 Рік тому

    Thank you!

  • @boggeshzahim3713
    @boggeshzahim3713 5 років тому

    This is so BADASS

  • @Diamonddrake
    @Diamonddrake 4 роки тому

    Great tutorial!

  • @udarakasun
    @udarakasun 6 років тому

    Thanks kevin. It's cool

  • @siriusgd4753
    @siriusgd4753 5 років тому

    Very nice!

  • @MartinHAndersen
    @MartinHAndersen 5 років тому

    Awesome, thanks again

  • @alexanderphilippovich3047
    @alexanderphilippovich3047 5 років тому

    Hi! Do you know how to move the omg picture a little to the right or top, by the x an y axis?

  • @Abhishek-tr4oi
    @Abhishek-tr4oi 5 років тому

    What a design awesome 😍

  • @fjworkshop
    @fjworkshop 3 роки тому

    can anyone tell me why we didn't use right in the ::before and top in the ::after?

  • @diegounanue
    @diegounanue 5 років тому +1

    Can you do the same with flex?

  • @Honza475
    @Honza475 5 років тому

    Liked and subbed. Very useful videos. Keep it up 👍

  • @pushpakgupta7396
    @pushpakgupta7396 5 років тому

    but when i do position absolute on card body instead of position relative then the card body goes to top left of the window....but your card remained there only...pls someone explain

  • @varsharaorane
    @varsharaorane 5 років тому

    very nice video

  • @nathancornwell1455
    @nathancornwell1455 5 років тому

    ever since i started doing Kevin's course on scrimba i just keep wanting to pause the video and look at the code lol

    • @amyp.575
      @amyp.575 5 років тому

      Same! And it's his only Scrimba which makes me sad! The CSS HTML one

    • @nathancornwell1455
      @nathancornwell1455 5 років тому +1

      @@amyp.575 indeed, I do hope to see him do more courses in the future. I wish he could do all his videos there instead of youtube but unfortunately thats not the way scrimba works....

    • @amyp.575
      @amyp.575 5 років тому

      @@nathancornwell1455 It's not? The only thing I know about Scrimba is that he was on it and the guy who tried to teach HTML was awful but this was after Kevin so I was comparing the two lol How do we talk him into making more?? Lol I can't learn from anyone else and I have tried and tried and tried! He has my future in his hands!! LOL

    • @nathancornwell1455
      @nathancornwell1455 5 років тому

      @@amyp.575 what i mean is how kevin uploads videos weekly on UA-cam..i wish he could do that on scrimba....kevin put out a course on responsive web design with CSS/HTML but he hasn't put more videos up because thats not how scrimba is , he would have to make a whole new course i assume..but i wish he could have like his videos on animations, transforms, etc on scrimba so we could play around with those while we learn but for now we have his youtube videos , codepens, and github.

  • @joaoribeiro9575
    @joaoribeiro9575 5 років тому

    Hi Kevin, I am still a bit confused, what is the difference between absolute and fixed when considering positioning? Thanks.

    • @vladmp5
      @vladmp5 5 років тому

      the position fixed is like an absolute, but makes the div "fixed" to where you placed it, and even if you scroll down, the element won't move up. Hope i helped :)

  • @meew7571
    @meew7571 5 років тому

    I have face some problem when i use position absolute...In Every Break point the position of the content is moving.. What is the trick to position absolute content responsive in every Device

    • @KevinPowell
      @KevinPowell  5 років тому

      Other than positioning it relative to the parent, there isn't much else we can do really.

  • @alenjose3903
    @alenjose3903 3 роки тому

    how does the before and after work to create the border

  • @joe-un1ky
    @joe-un1ky 5 років тому

    Damn, you're a CSS artist

  • @mrMinstrel
    @mrMinstrel 6 років тому

    Very Nice...thanks!

  • @geebee99singh
    @geebee99singh 5 років тому

    Sir do you have your blog or something where i can ask you designing related questions.

    • @KevinPowell
      @KevinPowell  5 років тому +1

      Sadly I don't. Could be something that I look into adding in the future though :)

  • @anuranjansrivastav9864
    @anuranjansrivastav9864 6 років тому

    Great video...

  • @mohammedriyazuddin5649
    @mohammedriyazuddin5649 6 років тому

    you are awesome man...

  • @AndrejDaiker
    @AndrejDaiker 6 років тому

    Awesome!

  • @alexanderphilippovich3047
    @alexanderphilippovich3047 5 років тому

    I mean the view of the picture, not changing the size. So Ican see the windows of the house for example.

  • @KashmirTechUniverse2432
    @KashmirTechUniverse2432 2 роки тому

    Which things makes Css responsiveness ?

  • @mk9834
    @mk9834 4 роки тому

    amazinggggg!

  • @anggamxfx476
    @anggamxfx476 6 років тому

    Da best keep it i love ur content

  • @mann3604
    @mann3604 6 років тому

    The class name totally depends on user right? or does card__image or card_image or cardImage or anything else makes any difference? I have seen a lot of people user _ in class names!

    • @KevinPowell
      @KevinPowell  6 років тому +1

      The class names are 100% your choice, you can use any name you'd like :).

  • @bijintsy
    @bijintsy 5 років тому

    awsome!!!

  • @MontyKsycki
    @MontyKsycki 5 років тому

    Thank You!!!! :)

  • @blokche_dev
    @blokche_dev 6 років тому

    Stylish! :)

  • @amyp.575
    @amyp.575 5 років тому

    why does the yellow on the outside on the right look like it's higher?

  • @LawnCrack
    @LawnCrack 6 років тому

    Killer!!!

  • @iancuvlad7368
    @iancuvlad7368 4 роки тому

    Applications are countless I can mention dropdown, ripple, dialogs etc

  • @webcodeexplainedYT
    @webcodeexplainedYT 4 роки тому

    How card pseudo element 'after' is getting rendered horizontal not vertical like 'before.

    • @Sayuiv
      @Sayuiv 4 роки тому +1

      Hi Rajender, Kevin put content: " "; that make it empy and then border: 1px solid white. At first you cannot see this border because you neither give them size or starting and finishing position. Defining left:3rem and right:3rem means that you want the border start a 3rem from the left and go to the right until 3rem, than with bottom: 1.5rem it is like giving a margin. So if you want the border vertical you define top and bottom, using only left or right for the horizontal alignment. If you want it horizontal you define left and right, using top or bottom for the vertical alignment. Hope it's clear.

    • @webcodeexplainedYT
      @webcodeexplainedYT 4 роки тому

      @@Sayuiv thanks for the reply. Its clear now 😌

  • @DrinkCola
    @DrinkCola 4 роки тому

    Dude ! We can do this card in Photoshop in a very easy way .

  • @syediqbalahmed3176
    @syediqbalahmed3176 5 років тому

    good

  • @JimKernix
    @JimKernix 3 роки тому

    Why is the body tag set to grid? And that the entire body is 100vh?

    • @KevinPowell
      @KevinPowell  3 роки тому

      Just to center the content for the demo :)

  • @nave3411
    @nave3411 6 років тому

    thanks

  • @laPas2024
    @laPas2024 6 років тому

    nice

  • @ozzyfromspace
    @ozzyfromspace 3 роки тому

    Ozzy Explains: why am I watching this?
    *1 minute in* ...
    font-family: “Oswald”, sans-serif; @1:00
    Say no more 😭😂

  • @jasonzhang2866
    @jasonzhang2866 6 років тому

    coool

  • @soumyajitdutta6780
    @soumyajitdutta6780 6 років тому

    thanks man.
    Make a video about "css slideshow".

    • @KevinPowell
      @KevinPowell  6 років тому +1

      Thanks for the suggestion, you' aren't the first to ask, so I'll see what I can do sometime in the future.