Create a diamond grid with CSS (with a bonus animation)

Поделиться
HTML-код
  • Опубликовано: 31 дек 2024

Комментарии • 141

  • @FlorinPop
    @FlorinPop 9 месяцев назад +48

    The king of CSS

  • @JeffWorthington
    @JeffWorthington 9 месяцев назад +37

    Not only a cool effect, but in going through your thought process ("hmm, why isn't that working?"), you help us understand how to think through this kind of problem generally.

  • @mrmibes
    @mrmibes 9 месяцев назад +15

    Such a handy tool and a great explanation for clip-paths. I really like seeing how you think through things too. Thanks, Kevin!

  • @romanperera
    @romanperera 9 месяцев назад +6

    I just love how you struggle and then find the solutions and reasons for that struggle. Thanks for explainng everything in an understanding way ✌😊

  • @seba9260
    @seba9260 9 месяцев назад +11

    love seeing your thought-process. thanks!

  • @joppekoops
    @joppekoops 9 месяцев назад +7

    I think that if you use relative paths, they are based on the size of the element they're on with percentages. That way, you don't have to worry about the size of the path anymore and it doesn't matter if the image is 4px bigger

  • @SuikerBossie
    @SuikerBossie 9 месяцев назад +3

    You're the man! Thanks Kevin ... always great to watch you. Learn so much from you!

  • @Dunc4n1d4h0
    @Dunc4n1d4h0 4 месяца назад

    @KevinPowell in that editor, you just have to rotate 45deg and center origin to have rounded corners on hover - just repeating workflow and having fun 🙂

  • @SlinkyCollins
    @SlinkyCollins 9 месяцев назад +1

    This is why i love checking out your videos, there's gotta be sth new you're gonna learn

  • @vontower
    @vontower 9 месяцев назад +87

    for the sake of engagement

    • @maidnuu
      @maidnuu 9 месяцев назад +11

      Congrats on the engagement!

    • @kylevandeusen
      @kylevandeusen 9 месяцев назад +1

      +1

    • @IceMetalPunk
      @IceMetalPunk 9 месяцев назад

      ​@@maidnuu What is this, Shayne and Courtney Topp? 😁 (I assume there's enough internet overlap that other people get the reference...)

  • @Patrick33456
    @Patrick33456 8 месяцев назад

    Just discovered your channel. Awesome content. Thanks for leaving in your head scratching moments, extremely helpful to see how people think through problems!

  • @jps9355
    @jps9355 8 месяцев назад +1

    Hiiiiiiii xD
    Great video. I've been practicing alot of css and watching alot of your videos (and also liking them). Thanks for the great content. 😊

  • @nathanwatts76
    @nathanwatts76 9 месяцев назад +2

    It would be awesome to see if you can make this responsive where the grid changes based on the screen size but you still keep the diamond pattern. Similar to the way you did in "Create an adaptive CSS grid with a max column count!".

  • @Rapand
    @Rapand 9 месяцев назад +7

    Leaving a comment for the sake of the algorithm. Also, great video, gonna use the setup for sure(minus hover effect)!

  • @mr_nesram
    @mr_nesram 9 месяцев назад

    Kev you're amazing bro! From you, I learned many things including not to stop working on something that "worked" but understanding how it's really working. And, if I get some error like you did using the border-radius property, i try to figure out why it is not working as expected!
    I know i'm talking with everybody's mouth when i say "I love you man"!

  • @DavidWatts
    @DavidWatts 9 месяцев назад

    What a gem! It looks great and I loved the explanation.

  • @alph0n5e_YT
    @alph0n5e_YT 8 месяцев назад

    Thanks for this great video! Inspired by this concept, I tried to create a hexagon-based grid in the same way. The math is a bit more involved due to the dimensions of a regular hexagon, but it was fun!

  • @iamreg1965
    @iamreg1965 8 месяцев назад

    I just created the diamond clip path with rounded corners and then a square clip path with rounded corners, and it worked fine,

  • @purringdemon
    @purringdemon 9 месяцев назад

    Keep up the great work, Kevin! Love your channel and content!

  • @soymuymuy
    @soymuymuy 9 месяцев назад +1

    Kevin! The keyframes hack is interesting. The way I have dealt with something similar in the past, is that I set additional transition for the z-index property, but in a way that enforces a "delay" of 500ms (in this case) before starting, and for the delayed transition, i just do "0s linear".

    • @maidnuu
      @maidnuu 9 месяцев назад

      Thank you, that's exactly what I've been thinking!

    • @KevinPowell
      @KevinPowell  9 месяцев назад +1

      Oh, yeah that would work as well! Bit cleaner too, since you don't need to set up some keyframes.

  • @ajoykrdas
    @ajoykrdas 9 месяцев назад +2

    Grid is too powerful!

  • @GuilhermeGomes-rd8zm
    @GuilhermeGomes-rd8zm 9 месяцев назад

    Thank you for the vid! And for sharing the path editor! Cheers from Brasil~

  • @LokiDaFerret
    @LokiDaFerret 9 месяцев назад +3

    I think the rotate feature in that path editor would have made that much simpler. It would obviously animate differently but would also be trivially simple to build.

  • @EricFressange
    @EricFressange 9 месяцев назад +1

    svg-path-editor added to my favorites thx :D
    What you can do @kevin to keep the border radius is to "turn" each 2 couple points corner of 45° to the left and place each point around your new four corners.
    By doing this you keep the border radius and you have a mask rotate + scale effect.

  • @TemurYusupov-g8z
    @TemurYusupov-g8z 7 месяцев назад

    You are king of the css

  • @eccenux
    @eccenux 8 месяцев назад

    Nice animations. I think I would use inkscape for the project like this. In inkscape you can add grid lines to snap points easily. Or click to align selected points vertically 😊

  • @arunsp767
    @arunsp767 9 месяцев назад

    15:32 When you were moving the points, I was internally screaming OH NO THE CORNERS 😂

  • @drewkillion2812
    @drewkillion2812 9 месяцев назад

    I would love more of these videos

  • @umairmughal6955
    @umairmughal6955 8 месяцев назад

    It's fun to watch you struggle and then figure it out on your own.

  • @tolgabeyazoglu536
    @tolgabeyazoglu536 7 месяцев назад

    hello good video why didn't we use border radius and rotation properties in image boxes or did I think wrong?

  • @shortyshorty9762
    @shortyshorty9762 8 месяцев назад

    What a great tutorial. Thank you very much for it. 😀👍

  • @KOBE42__
    @KOBE42__ 9 месяцев назад +1

    I love how happy and satisfied you get when you managed to insert the grid rows and they all came together 🙂
    I’m still confused how making the 4th child image span 2 managed to create the correct layout, how did that bit work?

    • @KevinPowell
      @KevinPowell  9 месяцев назад +2

      I'm having all of them span 2, but the 4th one is offset by 1 grid column, so it shifts over, along with the next one. 6th one doesn't have room now, so it goes to the next row

    • @KOBE42__
      @KOBE42__ 9 месяцев назад

      @@KevinPowellAhhhh right yeah that makes complete sense now! Thank you

  • @CatalinCalestru
    @CatalinCalestru 8 месяцев назад

    for the sake of engagement (actually cool videos, I learn a lot of new stuff, keep going :) )

  • @_whiteDemon
    @_whiteDemon 9 месяцев назад +1

    Much to learn here, but I'm still curious how border-radius and other border properties work when using custom paths

    • @albedesigns
      @albedesigns 8 месяцев назад +1

      border-radius property works independently of the clip-path property. It's used to round the corners of an element irrespective of its shape or clipping path. It applies to the visible area of the element AFTER the clipping path has been applied. Hope this helps!

  • @thevhejalltd8716
    @thevhejalltd8716 9 месяцев назад

    Great videos Sir, We want more videos like this😊

  • @seankennedy7970
    @seankennedy7970 9 месяцев назад +1

    Love this, need to find somewhere to use it. But will need to make it responsive.

    • @albedesigns
      @albedesigns 8 месяцев назад

      That's what I did - I changed the shapes a bit, made it responsive, and added javascript to it so that the images open up in a pop up modal & you can see them bigger. It was a lot of fun!

    • @CobaltStark
      @CobaltStark 7 месяцев назад

      @@albedesigns That's awesome, I've been trying for hours to do it but i'm struggling with the clip-path, I can't make it responsive while mantain its transition on hover (At least no without using JavaScript), can you share how you did it, i'd really appreciate that :)

  • @carolmckay5152
    @carolmckay5152 9 месяцев назад

    You are SUCH a great explainer!

    • @KevinPowell
      @KevinPowell  9 месяцев назад +1

      Thanks!

    • @LagrangePoint0
      @LagrangePoint0 8 месяцев назад

      @@KevinPowell Kevin, is there a way to display text over the image when hovering over it?

  • @cedwards1080
    @cedwards1080 7 месяцев назад

    Great video!

  • @fadi_mousa
    @fadi_mousa 9 месяцев назад

    You are the css MASTER 🎉

  • @wildandiamond
    @wildandiamond 9 месяцев назад

    Thanks for the tools, I really need it!

  • @LouieSonugan21
    @LouieSonugan21 9 месяцев назад

    Love it! Thank you Kevin!

  • @charlsey
    @charlsey 8 месяцев назад

    Thank you! Really appreciate this awesome tutorial and your thought process as you walk us through it! But I'm struggling to make it Responsive. Is there a way to make it responsive with just CSS? Or is it absolutely necessary to use JS or some other technology like Sass, or Bootstrap, etc... Would love to get your feedback on this.

  • @codetheworld6721
    @codetheworld6721 7 месяцев назад

    Awesome ❤

  • @Diamonddrake
    @Diamonddrake 9 месяцев назад +2

    I'm going to try to reproduce this with hexagons!

    • @_whiteDemon
      @_whiteDemon 9 месяцев назад +1

      Hexagons are the bestagons!

    • @albedesigns
      @albedesigns 8 месяцев назад

      Great idea!

  • @offgarde23
    @offgarde23 8 месяцев назад

    thank you wizard

  • @amirmekaiten2784
    @amirmekaiten2784 9 месяцев назад +1

    Had to leave a comment for the sake of engagement!

  • @felixjimenezgonzalez9292
    @felixjimenezgonzalez9292 9 месяцев назад

    Great video!
    Always learning something new 😄
    Have you covered 12 column layout in a video yet 😅? Or do you have any courses related to that?o you have any courses related to that?

  • @albedesigns
    @albedesigns 8 месяцев назад

    I don't think you have one video that I haven't learned something from!

  • @schwetang
    @schwetang 8 месяцев назад

    Hey Kevin. Loved this one, but how would I make that responsive?

  • @aliampichelmilan3345
    @aliampichelmilan3345 9 месяцев назад

    You'r the best 👑, nice video!

  • @penguinxed
    @penguinxed 9 месяцев назад +1

    grid is indeed very handy

  • @skreepatch2473
    @skreepatch2473 9 месяцев назад

    Looks good!

  • @RandomGeometryDashStuff
    @RandomGeometryDashStuff 9 месяцев назад

    21:42 but everything also get darker when hover between images

    • @KevinPowell
      @KevinPowell  9 месяцев назад +1

      If I use `:has()` it wouldn't. Because I'm doing it for the hover on the entire parent, then it does.

  • @Atlas_Steorra
    @Atlas_Steorra 8 месяцев назад

    Bravo 👏

  • @juanamorocho8521
    @juanamorocho8521 8 месяцев назад

    would it be possible to mirror the path horizontally and vertically in CSS and animate it?

  • @kill_switch_101
    @kill_switch_101 9 месяцев назад

    very cool

  • @tinongnjong1305
    @tinongnjong1305 9 месяцев назад

    For the sake of engagement it seems gap was taking up too much space, causing your border-radius not properly work.

  • @AJ-vy4yu
    @AJ-vy4yu 9 месяцев назад +3

    A comment for the sake of engagement

  • @kuraudotienda
    @kuraudotienda 8 месяцев назад +2

    That z-index hack was 🔥🔥🔥

  • @Cassandra81552
    @Cassandra81552 9 месяцев назад +1

    CSS lord

  • @flaviomauri
    @flaviomauri 8 месяцев назад

    I don't like the hover effect tbh, i would just like some zooming on the image, or the diamond pop up a bit with transform+shadow

  • @deadlyecho
    @deadlyecho 9 месяцев назад

    I used to suck at CSS although I loved creating creative effects, watching you all these years and trying to play with CSS stuff I learned has made me alot confidence when approaching designs ❤ although I am a backend engineer, learning to expand as Full Stack using the Angular 😂

  • @01Bluedragon
    @01Bluedragon 8 месяцев назад

    For anyone who want's to double the size I think this is the correct paths: /*This is double the size*/
    clip-path: path('M180,20 C200,0 200,0 220,20 380,180 380,180 380,180 400,200 400,200 380,220 380,220 220,380 220,380 200,400 200,400 180,380 180,380 20,220 20,220 0,200 0,200 20,180Z');
    /*clip-path: path('M90,10 C100,0 100,0 110,10 190,90 190,90 190,90 200,100 200,100 190,110 190,110 110,190 110,190 100,200 100,200 90,190 90,190 10,110 10,110 0,100 0,100 10,90Z');*/
    &:hover{
    /*This is double the size*/
    clip-path: path('M0,0 C0,0 400,0 400,0 400,0 400,200 400,200 400,200 400,400 400,400 400,400 200,400 200,400 200,400 200,400 0,400 0,400 0,200 0,200 0,200 0,200 0,200Z');
    /*clip-path: path('M0,0 C0,0 200,0 200,0 200,0 200,100 200,100 200,100 200,200 200,200 200,200 100,200 100,200 100,200 100,200 0,200 0,200 0,100 0,100 0,100 0,100 0,100Z');*/
    z-index: 2; /*on Hover put the image over the other images*/
    }
    I used scrimba.com/scrim/cocf6487e99264da4e193fec8

  • @Patrick-pu5di
    @Patrick-pu5di 4 месяца назад

    instead of messing with the z index i think you could just apply a perspective to the container and then transform:translateZ! then you dont need to bother with animations at all

  • @FeBe95
    @FeBe95 9 месяцев назад

    The aspect-ratio property does not seem to work correclty in Firefox. The portrait images are shown correctly while the landscape images are not filling the entire 2x2 grid cells. How could this be solved?

    • @KevinPowell
      @KevinPowell  9 месяцев назад

      Hmm, that's interesting. I might not have ever given them a width, so width:100% might do the trick. If not, I'd also add height: 100%

    • @FeBe95
      @FeBe95 9 месяцев назад

      @@KevinPowellOkay, that worked. I had to set it to 200% though (since they are overflowing their grid cell). Thanks!

  • @RandomGeometryDashStuff
    @RandomGeometryDashStuff 9 месяцев назад +2

    08:29 aren't your images 100px + .25rem + 100px because gap between columns?

    • @KevinPowell
      @KevinPowell  9 месяцев назад +2

      yup, I realize that close to the end 😅

  • @clevermissfox
    @clevermissfox 9 месяцев назад +3

    I wonder could you put each image in a parent, round the corners, rotate it, rotate the image back , overflow hidden then on the hover state , turn overflow: unset?

    • @KevinPowell
      @KevinPowell  9 месяцев назад +4

      The only issue is overflow can't be animated, so it would just jump from overflowing to not. Otherwise, yeah that would be a lot easier :)
      One option could potentially be to keep the overflow hidden, but rotate the child like you're saying, but also play with the scale... scale up the parent, scale down the child, and vice versa... Might work 🤔

    • @clevermissfox
      @clevermissfox 9 месяцев назад +1

      @@KevinPowell I'm just so terrible with paths and svgs , was trying to look through the lens of alternatives to clipPath 🤣 what's the transition-behaviour allow-discrete do for properties like display or overflow that don't animate?

  • @heavylog1c
    @heavylog1c 9 месяцев назад +1

    Now I wonder if I can do this with rotate and border-radius.

    • @KevinPowell
      @KevinPowell  9 месяцев назад +1

      You *might* be able to do it with a parent that has overflow hidden, and rotates. The image, which is the child, rotates the opposite way. The only thing is, you'd have to also animate the scale of the image to make it work, I think. Might be worth playing around with though.

  • @deatho0ne587
    @deatho0ne587 9 месяцев назад

    Think for yours, you should do 4 rows. Yes you only have 3 rows of images, but thinking if this was in a real project you either need a large margin-bottom or just 4 rows.

    • @KevinPowell
      @KevinPowell  9 месяцев назад

      Good point! I'd probably use a margin bottom, that way you could potentially have more images. I'd have to tweak my :nth-child() selector to make sure every second row was offset properly though.

  • @myanch200
    @myanch200 9 месяцев назад

    Alvaro also made Snake & Ladders in HTML+CSS with no JS total savage, I can't change the color of a button without downloading react, typescript, tailwind, shadcn etc etc

    • @KevinPowell
      @KevinPowell  9 месяцев назад +1

      I think he has a rock paper scissors as well... (might be mixing him up with someone else though). I won't be trying to remake any of those 😅

    • @myanch200
      @myanch200 9 месяцев назад

      @@KevinPowell Also saw a Quiz app made with only html css and it checks how many questions you have answered correctly madness

  • @hameeeed5992
    @hameeeed5992 7 месяцев назад

    nice video

  • @JananaYatharuth
    @JananaYatharuth 9 месяцев назад

    Now we just need to see bad apple played on clip path animation

  • @arctictern360
    @arctictern360 7 месяцев назад

    how do I use this code on elementor pro ?

  • @inanutshell6533
    @inanutshell6533 8 месяцев назад

    🎉

  • @nucleartux
    @nucleartux 9 месяцев назад

    awesome tricks

  • @peterbk364
    @peterbk364 8 месяцев назад

  • @myntsu
    @myntsu 9 месяцев назад

    Leaving a comment for the sake of engagement!

  • @AISHAISHWARYA
    @AISHAISHWARYA 9 месяцев назад

    Sir path operations konse appa se kiya hai

    • @KevinPowell
      @KevinPowell  9 месяцев назад

      The link is in the description 😁

  • @beanie-bosh
    @beanie-bosh 9 месяцев назад

    Anyone else experiencing an audio sync issue?
    Great video!

    • @KevinPowell
      @KevinPowell  9 месяцев назад +1

      I didn't notice any, and just double checked... but glad you liked the video regardless!

    • @beanie-bosh
      @beanie-bosh 8 месяцев назад

      @@KevinPowell just my Firestick it looks like. Thanks.

  • @nurikbk99
    @nurikbk99 9 месяцев назад

    🔥

  • @tithos
    @tithos 9 месяцев назад

    Cool

  • @rutikrathod2435
    @rutikrathod2435 9 месяцев назад

    Hello Please try midjourneys hero section

  • @Stoney_Eagle
    @Stoney_Eagle 9 месяцев назад

    Let's entertain the algorithm 😋

  • @pablorey9203
    @pablorey9203 9 месяцев назад

    nice!!!!!!!!!!!!!!

  • @SeanHoltWebDesigner
    @SeanHoltWebDesigner 9 месяцев назад

    Also for the sake of engagement.

  • @Trafalgar8Law
    @Trafalgar8Law 9 месяцев назад

    here, have some of my engagement

  • @MyDpop
    @MyDpop 9 месяцев назад +1

    I leave a comment for the sake of Engagement 🙃

  • @meraj5393
    @meraj5393 8 месяцев назад

    Forthe skae of engagement

  • @deadlyecho
    @deadlyecho 9 месяцев назад

    You should have scaled by 20 not 10 since you span 2 grid columns with an aspect ratio of 1 so your image is 200×200
    Edit: I noticed you figured it out later 😂

  • @TheCurz
    @TheCurz 9 месяцев назад

    I'm engaged 💍 for the sake of engagement LOL 😂😂

  • @ilyesbrh7667
    @ilyesbrh7667 8 месяцев назад

    for the sake of engagement

  • @wotr-wotr
    @wotr-wotr 8 месяцев назад

    Comment for the sake of engagement

  • @ryzzlas
    @ryzzlas 9 месяцев назад

    That clip-path cannot handle dynamic sizes (which is the whole point of vectors) is sooo disappointing. I wish this would get some attention. Because you could do so many cool things with it.

  • @PietervandenHombergh
    @PietervandenHombergh 9 месяцев назад

    you might have to rotate the path.

  • @handleman18
    @handleman18 9 месяцев назад

    😂😂 for sake of engagement

  • @conceptrat
    @conceptrat 9 месяцев назад

    Couldn't you have just drawn a square then rotated it and finally rounded the corners?

    • @KevinPowell
      @KevinPowell  9 месяцев назад

      To do it with images, I'd have to have a around each image, rotate the div one way, and rotate the image the other way, so that the image stays the right direction the entire time. I think you'd also potentially need to play with the scale of the image too, to ensure it's always big enough, but I haven't tried so I'm not sure. I did mention off the top that something like that is doable, but because I was basing it on what Alvaro did, I wanted to keep the HTML the same way he had it.

  • @clevermissfox
    @clevermissfox 9 месяцев назад +1

    And the curve arm thingies are called tangent handles. Also could you just put a border radius in the image for rounded corners? Sunce the clip path on hover isnt really for clipping its unclipping?
    Edit: I'm validated! Border radius on image!😂
    And does it have to be the same number of points or could you just say on hover, clip-path : none?

    • @KevinPowell
      @KevinPowell  9 месяцев назад +1

      Has to be the same number of points, or it doesn't animate. I tried 😆

  • @dave6012
    @dave6012 8 месяцев назад

    Commenting for reach

  • @alabamacajun7791
    @alabamacajun7791 9 месяцев назад

    Eight commercial breaks later ...

    • @KevinPowell
      @KevinPowell  9 месяцев назад +1

      Really? There shouldn't be that many, but I'll check my ad break thingy. YT must have got a little heavy handed on this one for some reason.

    • @alabamacajun7791
      @alabamacajun7791 9 месяцев назад

      @@KevinPowell After I wrote you, I went onto a live stream and the ad service was going bonkers. Others reported similar issues with lag. Sorry to bother you, I do enjoy the CSS mastering.

  • @scottl.696
    @scottl.696 9 месяцев назад

    Say muck one more time