3D CSS - lighting, animations, and more!

Поделиться
HTML-код
  • Опубликовано: 25 июл 2024
  • Having no idea how to do this myself, Amit Sheen was awesome enough to jump in and show me how it's done.
    You can find more from Amit Sheen here:
    ✅ His website: amitsh.com/
    ✅ Twitter: / amit_sheen
    ✅ Codepen: codepen.io/amit_sheen
    🔗 Links
    The CSS Tricks article that Amit mentioned, How CSS Perspective Works: css-tricks.com/how-css-perspe...
    ⌚ Timestamps
    00:00 - Introduction
    01:21 - Basic Set up
    09:04 - Giving the scene perspective
    12:28 - Making the cube
    22:35 - Making the ball 3D and adding the shadow
    27:56 - Rotating the scene
    31:34 - Making the ball bounce
    37:06 - Making the cube squish as the ball lands on it
    #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 RUclips 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!

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

  • @zachjensz
    @zachjensz 3 года назад +506

    Ohhhh, so this is that whole 'box model' thing in CSS 😜

  • @sadhlife
    @sadhlife 3 года назад +108

    Little tip: In physics class we're taught that the equation for the distance traveled by a falling ball is a quadratic equation. Which is why making the timing functions ease-in-quad and ease-out-quad would actually make it even more realistic feeling.

    • @sadhlife
      @sadhlife 3 года назад +32

      ease-in-quad = cubic-bezier(0.11, 0, 0.5, 0);
      ease-out-quad = cubic-bezier(0.5, 1, 0.89, 1);

  • @KennyCarter90
    @KennyCarter90 3 года назад +120

    I really like the format of this video, it's like two wizards teaching each other their tricks 🧙🏻‍♂️

  • @remkospaans
    @remkospaans 3 года назад +128

    The reverse animation on the ball 😱. I can’t stop 👀 at it.

    • @MerthanMerter
      @MerthanMerter 3 года назад

      like a boss

    • @frankcastle3288
      @frankcastle3288 2 года назад +1

      I wonder if removing the PRESERVE_3D would've also done the trick?

    • @naveenramkumar6123
      @naveenramkumar6123 2 года назад

      i dont understand that part at all...why does it have to be reverse?

    • @abdulsalphan
      @abdulsalphan 2 года назад +3

      @@naveenramkumar6123 The whole scene rotates at one direction, including the circle, which makes it look as a circle and not a sphere. When you reverse the rotation of the circle alone, it nullifies the rotation it gets from the whole scene.
      So, it basically doesn't rotate and gives us an impression that it is a sphere and not a 2D circle.

    • @abdulsalphan
      @abdulsalphan 2 года назад +1

      @@frankcastle3288 I thought if we could nail the circle from rotating, could do the trick.

  • @Morrile1
    @Morrile1 3 года назад +254

    Mind boggling CSS. Amit is much like Kevin, makes things look so easy whilst encouraging a desire to know more, love it 😎

  • @pablowbk
    @pablowbk 3 года назад +26

    Amit showing the crazy there-is-no-spoon trick on the "ball", Keving smiling "that makes me happy". I love this channel.

  • @carloseduardoramos9646
    @carloseduardoramos9646 Год назад +9

    I started my studies in CSS a month ago. My mind blowed just now, because all that i've heard untill yesterday was something like "CSS is for styles, and JS for add actions". Now im being introduced for a huge new world, full of possibilitys... the animations. Thank u guys for this pleasant start.

  • @abhyudaytripathi
    @abhyudaytripathi 3 года назад +152

    I was a Backend Developer, but now after discovering your channel, I now don't hate CSS (at least)

    • @orcave8802
      @orcave8802 2 года назад +8

      Knowing backend without mastering front end is useless atleast for me

    • @myname-mz3lo
      @myname-mz3lo 2 года назад

      front end dev can upload a site to cloud services and be ok . backend dev needs front end dev . soon only front end and cloud services will be there

    • @patfix
      @patfix 2 года назад

      Very relatable.

    • @connoisseurofcookies2047
      @connoisseurofcookies2047 2 года назад +1

      Difficult to create an impressive portfolio with zero front-end, especially if you're a junior dev.

  • @kelvinsmith4894
    @kelvinsmith4894 3 года назад +13

    Lol at that when he tricked my perspective of the ball with reverse rotation!
    This guy a legend! Shows he thinks rather than just code!😂

  • @antio1753
    @antio1753 3 года назад +6

    YEAAAAAAAAAAAAHHHHHHHHHH
    I LOVE 3d with css and RUclips has not enough video (or well structured) about it...
    PLEASE Kevin make a series for 3d with Css and of course with libraries like 3js....
    I am SURE that people would love them...especially with YOUR teaching style
    -With love, one of your students !

  • @lepsycho3691
    @lepsycho3691 3 года назад +3

    Man that was amazing! Thank you for bringing Amit to show his skills, very inspiring!

  • @edwardholmes91
    @edwardholmes91 3 года назад +23

    Wow, that's incredible, I never knew you could create such realistic effects using CSS. Amit's teaching style and way of explaining important concepts is fantastic. He's right, light and shade play such an important role in making things look realistic. I'm in awe, my CSS is very much armature by comparison but it's great to see what's possible!

  • @thecoderabbi
    @thecoderabbi 3 года назад +6

    This is so so so amazing! Thanks so much Kevin. I love the fact that you featured this 3D-CSS wizard, Love your enthusiasm in wanting to learn something new. Love that you're so much concerned about making CSS so much easier than it seem. I can't wait to see how easier you can make this to be when applying it to real web pages!!

  • @josvelema2362
    @josvelema2362 3 года назад +42

    That trick with the alpha on a hex value blew my mind ! Also this 3DCSS is not that hard to understand , it's really intuitive.

    • @dave6012
      @dave6012 3 года назад +2

      Careful. Safari calculates the Z-axis differently! I had a perfectly working 3d carousel that completely broke. Had to refactor the whole thing to work in safari as well as the other browsers.

    • @willjohnson4579
      @willjohnson4579 3 года назад

      @@dave6012 oh no, is it time to go to war for browser consistency again?

    • @dave6012
      @dave6012 3 года назад +2

      @@willjohnson4579 Gondor calls for aid!

  • @davidcordero9864
    @davidcordero9864 3 года назад +15

    Next level CSS. Kevin you looked inspired man! Can't wait to see where you take this, thanks for this fantastic video. Amit showed what a pro he is and a great teacher, bravo!

  • @bw-dude
    @bw-dude 3 года назад +7

    Hey Kevin, I watched a lot of your videos and learned something in each of them. But this one was a class of its own, absolutely mindboggling what Amit was doing. I could tell you felt the same way sometimes. Thank you!

  • @haythamkenway1561
    @haythamkenway1561 3 года назад +4

    oh my goodness ! you did it ! I was waiting for animation and you brought even more , thank you kevin You have my word 🙏❤

  • @EddyDarell
    @EddyDarell 2 года назад +3

    This tutorial is actually amazing. The ball animation and shadow tricks are just so simple yet yield so good results that I'm actually blown away. I'd have never thought of that. Thank you

  • @cephasmutua8639
    @cephasmutua8639 3 года назад +1

    Wow! Will have to set the 3D somewhere in my site. Thank you for the awesome teaching and thank you for inviting Amit.

  • @facundocorradini
    @facundocorradini 3 года назад +4

    So awesome! funny how your face (and mine) clearly reflected the excitement throughout the vid. I mean, CSS can feel somewhat magical at times, but in this one, Amit had us all amazed as if we were children watching an actual magician

  • @RunOs3
    @RunOs3 3 года назад +2

    CSS has always been an enigma to me. Amit is awesome and there are few like him out there in the front end world.

  • @d.l.3807
    @d.l.3807 3 года назад +12

    Just incredible. 50% of the video was just learning new stuff and I would say, I know quite something about CSS. Thanks for your tutorial!

  • @fanzheng1412
    @fanzheng1412 2 года назад +4

    It really makes a difference when you find out something this amazing is something you can do yourself. This actually makes me really want to learn webgl stuff, since animation with CSS takes too much CPU. This is a really inspiring video.

  • @JoeL-zw2me
    @JoeL-zw2me 3 года назад +3

    Really cool to see how something like this is made. Like you said not as complex as you’d think but just knowing how and what to do to accomplish it is the impressive part

  • @jimiscott
    @jimiscott 3 года назад +1

    This is totally amazing! Such a clear demonstration....so many concepts covered. Well done!

  • @sldentertainments9842
    @sldentertainments9842 2 года назад +1

    Never seen such a great video on CSS and never knew before that we can do so much things with just CSS!!! You guys are out of the world!! Thanks for amazing video🙏🙏

  • @ThePete98
    @ThePete98 3 года назад +3

    I always struggled with CSS as I mostly did back end dev, only working on styling when absolutely necessary and only enough to make things look reasonable, what I called functional not pretty. So inspiring to watch your videos and to get such insight. Fantastic

  • @peternicholson26
    @peternicholson26 2 года назад +1

    Even the simplicity of the chessboard style floor was epicly simple. Genius.

  • @Goloso333
    @Goloso333 3 года назад +2

    This stuff is fascinating and even though I haven't understood most of it because of the actual knowledge of 3D I am still very interested in learning more. Thank you for taking the time in sharing all this information. I am now a new follower of Amit Sheen. Thank you.

  • @swimmyJones
    @swimmyJones 2 года назад +5

    I've been doing straight up CSS for about a year now (getting away from Bootstrap when possible) and this video makes me feel like a beginner again lol.

  • @MyUbuntuVids
    @MyUbuntuVids 3 года назад +1

    Thank you, Kevin and Amit. This was a fantastic tutorial! You've whetted my appetite for CSS animation.

  • @pavanrao2965
    @pavanrao2965 3 года назад +3

    This video is super informative and absolutely stunning !!! ❤️ amazing content 👍 loved the animations especially the reverse animation on the ball 😍

  • @mritz579
    @mritz579 2 года назад +1

    This was amazing man! That reverse animation on the ball got me. So simple but soooooo effective. Thank you for all your videos. You definitely inspire me to create!

  • @elvisjames
    @elvisjames 3 года назад +1

    Your channel is a godsend. Brought back some inspiration to me, and the clean and concise delivery of the content is EVERYTHING. The thought process to use the knowledge bis what gets me excited
    Great content. Thanks.

  • @burhanahmed8767
    @burhanahmed8767 2 года назад

    Your Studio lighting is the best, I watched this video on a big screen, & seemed like you were sitting right before me.

  • @aCitizenJOSerased
    @aCitizenJOSerased 3 года назад +1

    Immense collaboration! Fantastic video. Makes you break down thing in your mind in a lot of new ways.

  • @astrit
    @astrit 3 года назад +3

    As always amazing. And this collaboration makes it even more interesting. Keep it up.

  • @rakeshpk4991
    @rakeshpk4991 3 года назад +1

    Thanks for inviting an amazing artist.

  • @holo23
    @holo23 3 года назад +1

    I've literally been binging your videos since I find them so enjoyable

  • @thydevdom
    @thydevdom 2 года назад +1

    The counter animation of the ball is badass! I would have never thought to do such a simple thing. lol

  • @dgtlbby
    @dgtlbby 2 года назад

    I'm new in the coding world and I can't believe all the free sources and the amount of amazing people sharing what they know, thank you so much Kevin and Amit!!

  • @technikhil314
    @technikhil314 3 года назад +2

    I will have to watch it at least 3-4 times to understand it fully. Great work.

  • @marianarlt
    @marianarlt 3 года назад +2

    Very cool to share this with everyone. Thanks for the effort! Extremely clever way to build a scenery in CSS and excellent attention to detail! I suppose most people know how positioning works, but this really shows how messed up CSS can be: "We give this element position: absolute, because it needs to be relative to the parent". Hahaha.

  • @OrvilleChomer
    @OrvilleChomer 2 года назад +1

    I just saw this. It was amazing! What was really cool is that I actually understood it! I was also encouraged that someone like Amit struggled with using the new CSS color syntax. If HE could struggle with that... helps alleviate some 'imposter syndrome!' Thanks for this video

  • @maclaurent1147
    @maclaurent1147 2 года назад +1

    Thank you for all the videos, you have really made me fall in love with CSS thank you so much and am learning alot.
    Keep up the gr8t work.

  • @guntherschabus3458
    @guntherschabus3458 3 года назад +1

    awesome guys! Idea, collaboration and deliverable. Really awesome 👍

  • @wallacce
    @wallacce 3 года назад

    Guys, you absolutely blew my mind. It's awesome! Thanks!

  • @ratias0
    @ratias0 3 года назад +2

    Thank you very much for this video. You both can make people fall in love with CSS.
    I'd only add an animation to make the ball darker when it bounces against the cube

  • @ir1n3l
    @ir1n3l 2 года назад +1

    I discovered your channel today, and 😮 wow, just blow my mind. I would like to see more of this video of people who work together. This will take me a year to recreate it 😅😅 awesome job, an awesome video awesome awesome awesome work. Love it!

  • @AsavarKul
    @AsavarKul 2 года назад

    Man, this sorcery classes are top notch

  • @funnybones1803
    @funnybones1803 3 года назад

    I just had this zen moment while watching. You guys are just great!

  • @nullpointer3860
    @nullpointer3860 3 года назад +2

    I have seen a couple of animations like this in css but honestly for most that I tray to understand the code I cannot, but this guy, wow just mind blowing...

  • @lemondrake0342
    @lemondrake0342 3 года назад +1

    Amazing, amazing stuff! Thanks so much, both of you! Learned a lot!

  • @vin-kry
    @vin-kry 3 года назад +1

    Superb! I was scrolling for such animation tutorial and suddenly a notification popped up from this Channel.

  • @willjohnson4579
    @willjohnson4579 3 года назад +4

    and just like that i have a better grasp of 3D CSS, what an amazing 3D animation lesson, and in just 45 minutes!

  • @glitchpixels5303
    @glitchpixels5303 3 года назад

    Insane I'm in love with CSS now Hat's off to the legend Amit Sheen and ton of love for Kevin Powell for sharing this with us

  • @PhotographyAdventure
    @PhotographyAdventure 5 месяцев назад

    This was so inspirational, amazing walkthrough! 🙏🏼

  • @tanakakun6093
    @tanakakun6093 3 года назад

    Finally finished doing this, It was actually fun to do. I got a bit of trouble at the start because firefox doesnt support perspective. But switched to Chrome to testing and its working. Thanks for teaching me this!

  • @crowebro9581
    @crowebro9581 2 года назад +1

    Wow! This was amazing to watch and learn. I am eager to try this.

  • @emashno5
    @emashno5 3 года назад +1

    I just love how people are seeing that css and css3 three can produce insane stuff nice work Amit and Kevin

  • @8koi245
    @8koi245 2 года назад

    This is so cool!!!
    I'm so glad I decided to work on this

  • @tejasrao3559
    @tejasrao3559 3 года назад

    I love CSS and started loving it more after seeing this video, your channel us amazing!

  • @stevebob240
    @stevebob240 2 года назад

    That was awesome, very informative. I'd love to see Amit on again.

  • @Viktor920
    @Viktor920 Год назад

    That was super fun and super useful, thank you!

  • @Voughnfox
    @Voughnfox 3 года назад

    AWESOME! Superb talent! thank you Amit Sheen and Kevin Powell.

  • @NoztrozeR
    @NoztrozeR Год назад

    This was fantastic. I really hope you can get Amit back for some more CSS magic in the future!

  • @mhyeganeh
    @mhyeganeh 3 года назад

    Awesome Collaboration! 👍👏 So much new stuff to learn. Thx

  • @ashleyhoward14
    @ashleyhoward14 3 года назад

    I love your collabs! They're so interesting

  • @FrankKynard-yf9yu
    @FrankKynard-yf9yu Год назад

    People were talking about the ball this dude made a floor. I was completely mystified at the floor.
    The shadowing on the floor just made the whole thing real

  • @codaniel
    @codaniel 2 года назад +1

    Very interesting, I love the collaboration.

  • @sebap_xc
    @sebap_xc 2 года назад

    Thanks both of you for this great video!

  • @jericovalino4976
    @jericovalino4976 3 года назад +2

    I'm so much in to the video that i forgot to comment "first" lol 😂.. This video is one of my favorite from this channel. Hope to see more content like this in the future.. Thanks for this!

  • @gowravkumar7251
    @gowravkumar7251 3 года назад

    This was so awesome. Loved it 😍😍

  • @JBWEBDEVELOPER
    @JBWEBDEVELOPER 3 года назад

    Man am just blown away with the 3d, its really amazing

  • @antoniocebrian8379
    @antoniocebrian8379 2 года назад

    You made my day with this video. Thank you!

  • @alaaalaff-6252
    @alaaalaff-6252 2 года назад +1

    Thanks a lot, It's very cool 3d animation with cool and creative codes 😍🥳

  • @alykane6347
    @alykane6347 2 года назад +1

    We're also happy, Kevin! Idid some 3D design with cinema 4D but I couldn't believe it possible with css. Great! Great! Great!

  • @josevaltierra8360
    @josevaltierra8360 2 года назад +2

    I just saw this tutorial and I only made a couple of changes to make it fit in the animation, thank you very much for this content, I have always liked animations with css but sometimes it is very difficult for me to understand the language, still I hope that keep it up, greetings from Mexico.
    I should add that I also use an extension called live Saas Compiler and this will generate the css that you can add to the html.Here I leave the css I hope it helps you
    :root
    {
    --boxColor:#0ff7;
    --rotateSpeed:30s;
    --bounceSpeed:2s;
    }
    body
    {
    background-color: #000;
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 75px;
    perspective:10em;
    perspective-origin: 50% calc(50% - 2.5em);

    }
    .scene
    {
    position: relative;
    transform-style: preserve-3d;
    animation: sceneRotate var(--rotateSpeed) infinite linear ;
    @keyframes sceneRotate {
    to {transform: rotateY(360deg); }
    }
    }
    .ball
    {
    width: 1em;
    height: 1em;
    border-radius: 50%;
    background: lightblue;
    position: absolute;
    left: -.5em;
    bottom: 1em;
    background-image: radial-gradient(
    circle at top,
    lightblue,
    #000
    );
    animation:
    ballBounce var(--bounceSpeed) infinite ease-out,
    sceneRotate var(--rotateSpeed) infinite linear reverse;
    @keyframes ballBounce {
    0%,100% {bottom: 0.5em;}
    50% {bottom: 3em; animation-timing-function: ease-in;}
    }
    }
    .ballShadow
    {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(
    #0007,#0000 50%
    );
    animation:
    ballShadow var(--bounceSpeed) infinite ease-out;
    @keyframes ballShadow {
    0%,8%,93.5%,100% {transform: scale(1); opacity: 1;}
    50% {transform: scale(2); opacity: 0.5; animation-timing-function: ease-in;}
    }
    }
    .cube
    {
    width: 2em;
    height: 2em;
    transform-style: preserve-3d;
    position: absolute;
    bottom: -1em;
    left: -1em;

    animation: cubeHeight var(--bounceSpeed) infinite linear;
    @keyframes cubeHeight {
    0%,100% {height: 1.5em;}
    8%,93.5%{height: 2em;}
    }
    .left,.right,.front,.back{
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--boxColor);
    box-shadow: 0 0 0.5em #000a inset;
    }
    .front{transform: translateZ(1em);}
    .right{transform: rotateY(90deg) translateZ(1em);}
    .back{transform: rotateY(180deg) translateZ(1em);}
    .left{transform: rotateY(270deg) translateZ(1em);}
    .top{
    position: absolute;
    width: 2em;
    height: 2em;
    background: var(--boxColor);
    transform: translateY(-50%) rotateX(90deg);
    box-shadow: 0 0 0.5em #000a inset;
    }
    .bottom{
    position: absolute;
    width: 2em;
    height: 2em;
    background: #0007;
    bottom: 0;
    transform: translateY(-50%) rotateX(90deg);
    box-shadow: 0 0 0.5em #000;
    }

    }
    .floor
    {
    position: absolute;
    top: 1em;
    transform: translate(-50% , -50%)
    rotateX(90deg);
    width: 15em;
    height: 15em;
    background-image:
    radial-gradient(#0000,#000 75%),
    repeating-conic-gradient(from 45deg,
    #111 0deg 90deg,
    #222 90deg 180deg);
    background-size: 1em 1em;
    }

  • @dipanjandeb5245
    @dipanjandeb5245 3 года назад +1

    Absolutely mind blown!!
    Take a bow!

  • @NirangaDeSilva
    @NirangaDeSilva 3 года назад

    Mind Blown..!!! 🤯🤯🤯🤯 Thanks a lot Kevin & Amit..!! Cheers..!!

  • @themightysapien
    @themightysapien 2 года назад

    Man what did I just watch. DAMN my dude is a beast.

  • @prasathj7436
    @prasathj7436 11 месяцев назад

    In just one word, Amazing !!!

  • @mansukong
    @mansukong 3 года назад +3

    Is this possible?
    Wow! That's amazing!

  • @danielhbrito
    @danielhbrito 3 года назад +1

    Mindblowing experiment! Thanks for sharing this knowledge.

  • @AbWischBar
    @AbWischBar 3 года назад +3

    I am not sure, whether I would use 3D CSS in this way (since I need to go full WebGL for my projects), but ... this is amazing 👍. Just to know that all of this can be done is super valuable. And a lot of the demonstrated techniques will apply to other situations.
    Just mind blasted again and again by the capabilities of the web render engines.

  • @minggy1923
    @minggy1923 2 года назад +1

    So great! Thank you to you both, I learned so much :))

  • @wanyi8761
    @wanyi8761 3 года назад

    This is literally mind blowing

  • @elenagolubeva4149
    @elenagolubeva4149 Год назад

    I learned so much 😱 amazing work and great explanations!

  • @codemplified4978
    @codemplified4978 3 года назад

    watch 3d room view, built with just html and css
    ruclips.net/video/XCLR1JVYQxU/видео.html
    full code view:
    ruclips.net/video/ILTiZFNmQtc/видео.html

  • @Showbear1986
    @Showbear1986 2 года назад

    So awesome to watch. Makes me smile ;)

  • @upl1nk.v01d2
    @upl1nk.v01d2 2 года назад

    Amit is legendary! Thanks for sharing this!!

  • @ahmedelmansi6497
    @ahmedelmansi6497 3 года назад +1

    these is the best live chat i have ever seen :D

  • @MahadyHasan
    @MahadyHasan 2 года назад

    How beautiful is it! wow. But it is never easy to work, more and more complex than CSS hack. Especially for 3D animation in any platform, you have to think about lots of things, keyframe, timing, lighting, axis, and more. Mr. Amit Sheen did this in a very easy way that we see and behind this effort has many years of experience.

  • @iiREYteoii
    @iiREYteoii Год назад

    I'm really impressed on how he explains, i just know the basic css and understood pretty well 👏

  • @rian438
    @rian438 3 года назад +3

    Holy cow this is so cool.

  • @hanavoriskova5297
    @hanavoriskova5297 2 года назад

    mind blowing! thank you for all the information! :)

  • @pcartisan2721
    @pcartisan2721 3 года назад

    AWESOME!
    Thank you two.

  • @vickmackey24
    @vickmackey24 2 года назад

    Super cool. Excellent presentation.

  • @matiasespinosa465
    @matiasespinosa465 2 года назад

    Incredible!! Thanks for such amazing content, im learning a lot with your videos. Greetings from Argentina

  • @holo23
    @holo23 3 года назад

    Well that was a journey, I really learned a lot from this oh wow, especially the inset on box shadow