Make position absolute work with you, not against you

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.พ. 2025

ความคิดเห็น • 39

  • @tithos
    @tithos 10 หลายเดือนก่อน +11

    Kevin, my respect for you are a teacher has gone up 100 fold. this video, responding personally to a student, is priceless!!

  • @chrisicotec7652
    @chrisicotec7652 10 หลายเดือนก่อน +6

    i had no idea you can just write the class name in codepen html and it wraps it in div tags automatically,

    • @goodshiro10
      @goodshiro10 10 หลายเดือนก่อน +3

      That's because of the tool called Emmet.
      It's to make our life easier by providing shortcuts to create elements.
      example, #elementId would create an element with the id "ElementId"

    • @chrisicotec7652
      @chrisicotec7652 10 หลายเดือนก่อน

      @@goodshiro10 good to know, tbh ive heard of emmet but had no idea what it was so never bothered to use... discovering this has now made my workflow so much easier

  • @daveskye
    @daveskye 10 หลายเดือนก่อน +6

    Why multiply the pixel size? I would never have considered that as a way to do it. - If you want things to scale based on one element I would use rem as the parent and em as for child elements. Or percentage.

    • @KevinPowell
      @KevinPowell  10 หลายเดือนก่อน +2

      It was pretty specific to this use case, which I probably should have mentioned. Because it's for a game and everything is drawn in CSS it makes sense this way

  • @Atractiondj
    @Atractiondj 10 หลายเดือนก่อน +16

    Soon - css anchor

    • @KevinPowell
      @KevinPowell  10 หลายเดือนก่อน +9

      Looking forward to it!

    • @TesterAnimal1
      @TesterAnimal1 10 หลายเดือนก่อน

      Bleh. I doubt it will do what people need flexibly enough. The committees never end up with really usable things. Who seriously uses ? They’re all hideous.
      I’ll stick with my own adaptive alignment technique.

    • @LePhenixGD
      @LePhenixGD 10 หลายเดือนก่อน

      This is a game changer, with that you absolutely position without having the element nested!!!

    • @Atractiondj
      @Atractiondj 10 หลายเดือนก่อน

      @@TesterAnimal1 Most likely, you have not yet encountered a problem where exactly this will help you solve the problem very simply. I, too, when I saw Interop 2024, was not very impressed until I began to analyze each item separately.

    • @MattDunlapCO
      @MattDunlapCO 10 หลายเดือนก่อน

      ​@@TesterAnimal1that's often true, but having tested anchor positioning quite extensively now (in Chrome canary), it's going to be as big as flex and grid. For popovers the benefit is clear, but there are a ton of other things it unlocks we've never been able to do without js.

  • @LePhenixGD
    @LePhenixGD 10 หลายเดือนก่อน +1

    9:20 LOL, well since the pixel size is 5px and you want to get 400px, you simply do 400÷5 which is 80, thus you have to multiply the pixel-size by 80px

  • @user-vatican
    @user-vatican 10 หลายเดือนก่อน +1

    hello Paul, a beginner in site layout, I had a problem with css when I made up a regular filling form, checked through the code inspector, so when minimizing the window, the form does not turn out to be adaptive, can you tell me what to do for this?

  • @codedjango
    @codedjango 10 หลายเดือนก่อน +2

    how to stick a div on scroll? I have a table of index in a div which I want to stick to its position when the user scrolls down a bit...

    • @KevinPowell
      @KevinPowell  10 หลายเดือนก่อน +2

      position: sticky can probably do it, though there are some limitations in how it works. I'd start with that though, from the sounds of it :)

  • @easysolutions8628
    @easysolutions8628 10 หลายเดือนก่อน

    Thanks for the video Sir❤

  • @eioluseyi
    @eioluseyi 10 หลายเดือนก่อน +6

    I believe it could have been a lot easier if Drew used rem to manage the scaling.
    calc(var(--pixel-size) * 3); could have just been 3rem;

    • @stephaniepeters2590
      @stephaniepeters2590 10 หลายเดือนก่อน

      The rem, though, is always tied to the body font-size. This might respond poorly to font-size changes of elements on the page. Possibly em is also a good thing to use. If you need to depend on a size that is not tied to rem or em, the CSS custom prop is indeed the way to go.

  • @clevermissfox
    @clevermissfox 10 หลายเดือนก่อน +3

    Gosh, I adore custom properties. So useful.
    Also nesting. I didn’t realize how much I needed nesting for organization until I stopped using for a second because one user was back on an unsupported browser and everything broke.

    • @MartynMc
      @MartynMc 10 หลายเดือนก่อน +4

      That's why I love SASS/SCSS, get all the benefits of modern CSS and nesting without the adopter bugs and grievances.

  • @amit.agrahari
    @amit.agrahari 10 หลายเดือนก่อน

    Kevin, in 14" laptop default windows display/ resolution set as 150% and that impact on browser resolution. Can we reset browser resolution with css?

  • @FrankRoos-b8q
    @FrankRoos-b8q 10 หลายเดือนก่อน

    This becomes so much easier with container queries, and relating everything to cqw and cqh. No more calc. Let the browser do the math.

  • @irvinmuziwenkosi
    @irvinmuziwenkosi 10 หลายเดือนก่อน +1

    "front end friends" 😅

  • @Waviiie
    @Waviiie 10 หลายเดือนก่อน

    is there a way to set an absolute element relative to its sibling?

    • @bn5055
      @bn5055 10 หลายเดือนก่อน

      No. It has to be a parent. But you can have the sibling not be absolutely positioned and only absolutely position one element, which is kinda sorta the same thing.

  • @Stoney_Eagle
    @Stoney_Eagle 10 หลายเดือนก่อน +1

    Knowing that the absolute x and y is based on the first surrounding element that defines its position as relative goes a long way 😊
    If only we could do absolute and relative on the same element so we don't need a relative child for its children to be relative to the absolute element 😂

    • @dylanclarke9497
      @dylanclarke9497 10 หลายเดือนก่อน +4

      Absolute elements actually take their positions from the nearest positioned element, not just ones that are relative. An element is considered to be positioned if its position property is set to anything other than “static” (the default) so I think you should be able to absolutely position children relative to their absolutely positioned parent

  • @alexandrtcacenco8129
    @alexandrtcacenco8129 10 หลายเดือนก่อน

    from mozilla docs: ... The element is positioned relative to its closest positioned ancestor

  • @rafa6536
    @rafa6536 10 หลายเดือนก่อน +1

    Hello friend :)

  • @muhdkamilmohdbaki7054
    @muhdkamilmohdbaki7054 10 หลายเดือนก่อน +3

    Absolute power corrupts absolutely. Absolute CSS position corrupts my TH-cam feeds🤭.

  • @crazy_hardcore_gaming
    @crazy_hardcore_gaming 10 หลายเดือนก่อน +2

    first

  • @tsr1012
    @tsr1012 10 หลายเดือนก่อน +1

    I find myself using absolute most of the time..

    • @evolutionxbox
      @evolutionxbox 10 หลายเดือนก่อน +4

      Most of the time??? Why?

    • @Joseph-bgt5zaq1
      @Joseph-bgt5zaq1 10 หลายเดือนก่อน +1

      I'd be scared for my future self if I was using absolute positioning in more than a handful of cases

    • @bn5055
      @bn5055 10 หลายเดือนก่อน

      Don't scale your browser window...

  • @user-vatican
    @user-vatican 10 หลายเดือนก่อน

    hello Paul, a beginner in site layout, I had a problem with css when I made up a regular filling form, checked through the code inspector, so when minimizing the window, the form does not turn out to be adaptive, can you tell me what to do for this?