Make position absolute work with you, not against you

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

КОМЕНТАРІ • 39

  • @tithos
    @tithos 6 місяців тому +11

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

  • @Atractiondj
    @Atractiondj 6 місяців тому +16

    Soon - css anchor

    • @KevinPowell
      @KevinPowell  6 місяців тому +9

      Looking forward to it!

    • @TesterAnimal1
      @TesterAnimal1 6 місяців тому

      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 6 місяців тому

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

    • @Atractiondj
      @Atractiondj 6 місяців тому

      @@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 6 місяців тому

      ​@@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.

  • @daveskye
    @daveskye 6 місяців тому +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  6 місяців тому +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

  • @eioluseyi
    @eioluseyi 6 місяців тому +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 6 місяців тому

      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.

  • @chrisicotec7652
    @chrisicotec7652 6 місяців тому +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 6 місяців тому +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 6 місяців тому

      @@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

  • @easysolutions8628
    @easysolutions8628 6 місяців тому

    Thanks for the video Sir❤

  • @clevermissfox
    @clevermissfox 6 місяців тому +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 6 місяців тому +4

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

  • @LePhenixGD
    @LePhenixGD 6 місяців тому +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

  • @codedjango
    @codedjango 6 місяців тому +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  6 місяців тому +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 :)

  • @user-vatican
    @user-vatican 6 місяців тому +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?

  • @FrankRoos-b8q
    @FrankRoos-b8q 6 місяців тому

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

  • @Stoney_Eagle
    @Stoney_Eagle 6 місяців тому +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 6 місяців тому +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

  • @irvinmuziwenkosi
    @irvinmuziwenkosi 6 місяців тому +1

    "front end friends" 😅

  • @alexandrtcacenco8129
    @alexandrtcacenco8129 5 місяців тому

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

  • @rafa6536
    @rafa6536 6 місяців тому +1

    Hello friend :)

  • @Waviiie
    @Waviiie 6 місяців тому

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

    • @bn5055
      @bn5055 6 місяців тому

      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.

  • @muhdkamilmohdbaki7054
    @muhdkamilmohdbaki7054 6 місяців тому +3

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

  • @crazy_hardcore_gaming
    @crazy_hardcore_gaming 6 місяців тому +2

    first

  • @tsr1012
    @tsr1012 6 місяців тому +1

    I find myself using absolute most of the time..

    • @evolutionxbox
      @evolutionxbox 6 місяців тому +4

      Most of the time??? Why?

    • @Joseph-bgt5zaq1
      @Joseph-bgt5zaq1 6 місяців тому +1

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

    • @bn5055
      @bn5055 6 місяців тому

      Don't scale your browser window...

  • @user-vatican
    @user-vatican 6 місяців тому

    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?

  • @amit.agrahari
    @amit.agrahari 6 місяців тому

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