The border property you never knew you needed

Sdílet
Vložit
  • čas přidán 8. 05. 2024
  • The border-image property is a blast from the past for anyone who had to make buttons with round corners on them back in the 2000s, but these days we can use it for fun gradient effects too!
    🔗 Links
    ✅ Mozilla border image generator: developer.mozilla.org/en-US/d...
    ⌚ Timestamps
    00:00 - Introduction
    00:47 - Looking at the basics with an image
    03:07 - Making sense of border-image-slice
    05:28 - Using border-image-repeat
    07:10 - The fill keyword
    09:00 - Gradient example one
    11:04 - Gradient example two
    12:05 - Gradient example three
    #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 CZcams 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!

Komentáře • 184

  • @zachjensz
    @zachjensz Před rokem +314

    This is borderline fantastic

    • @KevinPowell
      @KevinPowell  Před rokem +53

      🥁

    • @-_._._-
      @-_._._- Před rokem +18

      This comment should be pinned for posterity :P

    • @sonjadilan777
      @sonjadilan777 Před rokem +1

      🤣💪🏾🔥😎

    • @notfireman
      @notfireman Před rokem +4

      No, this is borderline godtier. Saying borderline fantastic is the same as saying barely fantastic

    • @kdot78
      @kdot78 Před rokem +8

      @@notfireman okay Shakespeare

  • @graysonpeddie
    @graysonpeddie Před rokem +9

    I have just implemented the transparent gradient border in my website thanks to you! Awesome! I actually use it in an :after element behind the semi-transparent background for my articles with the z-index set to -1. 😃

  • @kncle
    @kncle Před rokem +10

    This is so cool. I want to see more of these little design hacks for common designs patterns.

  • @Luxalpa
    @Luxalpa Před měsícem +1

    5:38 "This isn't what you'd think it is" - that's a great description of CSS properties in general!

  • @Vattevaii
    @Vattevaii Před rokem +1

    Damn .. been searching all over the place for gradient borders.. I just used to add multiple backgrounds with proper positioning and size to emulate gradient borders.. or just layer ::before to get gradient border..
    This was too informative
    Love you bro

  • @__anasmustafa
    @__anasmustafa Před rokem

    Get well soon Kevin!
    Great content as always!

  • @j7coder
    @j7coder Před rokem

    Amazing!!
    You make me fall in love with css!

  • @user-sy7lm6lw8i
    @user-sy7lm6lw8i Před rokem

    Perfect, I am coding my small project now, as I am not a designer i try to make things look simple, but i always want to add some artistic touch to them. The transparent border is something i need)

  • @shakirdodhiya8770
    @shakirdodhiya8770 Před rokem +3

    Nice content Kevin
    I also used gradient borders in some of my recent projects
    One drawback is that it doesn't work with border radius

  • @sergnio
    @sergnio Před rokem +3

    I couldn't figure out why it wasn't working, but of course coming to a Kevin Powell video you learn exactly what you need

  • @YurijVolkov
    @YurijVolkov Před rokem

    Last time I use border-image when it was as an exercise in a paper tutorial book and it was almost useless in real world. But now, with a gradient, that might be usable! Thanks!!

  • @sabiruli
    @sabiruli Před rokem

    This is amazing! Thanks @Kevin

  • @TheRalic
    @TheRalic Před rokem +1

    Excellent video, never used borders like that and I think I will start using it from now on ^_^

  • @chrisozz2007
    @chrisozz2007 Před rokem

    this was great. was able to use it immediately at work. Thanks

  • @angrytvrobot6130
    @angrytvrobot6130 Před rokem

    Holy crap this is mindblowing. Thank you! I'm going to mess around with this on my current project.

  • @askjamesss
    @askjamesss Před rokem +1

    KP CSS Tutorials as it's finest. ☝️🙌

  • @balubalaji9956
    @balubalaji9956 Před rokem

    enjoyed the examples at the end.. just wow

  • @giorgiteliashvili5268
    @giorgiteliashvili5268 Před měsícem +1

    Thanks for your explanation, very clear and helpful, fantastic!

  • @nonchain
    @nonchain Před rokem

    Man you just saved my life with this tutorial
    Thanks a lot

  • @anaselhassani2545
    @anaselhassani2545 Před rokem

    THANK YOU SO MUCH FOR THIS VIDEO

  • @bilatungdulang9708
    @bilatungdulang9708 Před rokem

    Really fantastic thing from border image, thanks for sharing my friend

  • @Vector99
    @Vector99 Před 3 měsíci

    This is really cool. Thank you sir!

  • @peternicholson26
    @peternicholson26 Před rokem

    that was some pretty slick border action. I need to inject this knowledge into the designers at work so they only design based off the things I already know ha

  • @solaarsslave
    @solaarsslave Před rokem

    i almost always learn something new, thanks!

  • @StevenDavisPhoto
    @StevenDavisPhoto Před rokem

    Omigosh! I didn't know this was doable! This video would have helped when I needed to do a gradient border a while back. Dang. Haha.

  • @millos0116
    @millos0116 Před rokem

    I really enjoy your tutorials, voice and positive energy, God bless you brother🙏💙

  • @nicholaskane69
    @nicholaskane69 Před rokem

    I use these to put 'Final Fantasy 7'-style borders around UI elements on my Twitch streams. They're great!

  • @oleksandrvorovchenko8674

    Thanks! Very useful, as usual.

  • @thedelanyo
    @thedelanyo Před rokem

    Your video contents are top notch Sir . Thanks.

  • @j.almadhaji
    @j.almadhaji Před rokem

    Well, that's new
    Thank you Kevin

  • @n0n1m
    @n0n1m Před rokem

    Mind blowing and really beautiful:)

  • @WarframeCrunch
    @WarframeCrunch Před rokem

    Thanks for that, I didn't known about border-image

  • @mikodizon8322
    @mikodizon8322 Před rokem

    great video! Thanks kevin!

  • @GauravKumar-ue7nz
    @GauravKumar-ue7nz Před rokem

    Thanks Kevin

  • @matthewblasco4720
    @matthewblasco4720 Před rokem

    🤩🤩🤩🤩 ty for making css awesome

  • @piterparker990
    @piterparker990 Před rokem

    its work thx brother 🙏

  • @chrisicotec7652
    @chrisicotec7652 Před rokem

    css used to stress me out, this channel makes it much less scary and confusing

  • @quintenmantez6934
    @quintenmantez6934 Před rokem

    Nice!!! Thx!

  • @haliszekeriyaozkok4851

    Very beautiful.

  • @smsmsmow4109
    @smsmsmow4109 Před rokem

    wow >> you are amazing

  • @tcgvsocg1458
    @tcgvsocg1458 Před rokem

    genius! thx a lot

  • @uc9773
    @uc9773 Před rokem

    Such a cool things~ thx

  • @blackcheetah4550
    @blackcheetah4550 Před 11 měsíci

    Very useful video, thanks

  • @MrAsgardian1987
    @MrAsgardian1987 Před rokem

    You just saved me some serious design headache (Y)

  • @AlvinIsChipmunk
    @AlvinIsChipmunk Před rokem +3

    for gradient border i always use background: linear-gradient and changing border to transparent.
    background:
    linear-gradient(#fff 0 0) padding-box,
    linear-gradient(to right, #9c20aa, #fb3570) border-box;
    border: 10px solid transparent;
    first linear-gradient is basically your background color to fill only the padding box while sitting on a second linear gradient which is the gradient that fills to the whole border area.

    • @Way_Of_The_Light
      @Way_Of_The_Light Před rokem +1

      Hey quick question, How do you make the border show up inside the box? Like an inner frame of a Tarot Card? 🙏

    • @AlvinIsChipmunk
      @AlvinIsChipmunk Před rokem

      @@Way_Of_The_Light I only know how to do it with solid colors with box-shadow inset... Or a negative outline-offset.. creating a pseudo element sortof works too(by making width and height smaller than the parent)...

    • @mcnagynorbi
      @mcnagynorbi Před rokem

      @@Way_Of_The_Light You can have two borders actually. You can use outline as a second border around it.

    • @Way_Of_The_Light
      @Way_Of_The_Light Před rokem

      I see, Thanks for the answers guys 🙏

  • @paulooliveira8976
    @paulooliveira8976 Před 3 měsíci

    Welcome to the styling side!!

  • @overwatch9659
    @overwatch9659 Před rokem

    Great video 🙏🏾🖤

  • @arshad1781
    @arshad1781 Před rokem

    Thanks 👍

  • @wayneswildworld
    @wayneswildworld Před rokem

    Awesome video!!!

  • @eothica
    @eothica Před rokem

    lol saved me hours with that mozilla border image generator

  • @StefanoVolponi
    @StefanoVolponi Před rokem

    The first 30 seconds are enough to make me feel oooooooooooooold

  • @lazy07
    @lazy07 Před rokem

    Nice video will help me in my next Website 👍

  • @sarsario
    @sarsario Před rokem

    Good stuff

  • @Sean-Smith-Photos
    @Sean-Smith-Photos Před rokem

    Very cool

  • @danisob3633
    @danisob3633 Před rokem

    I love it

  • @tworsfeline2302
    @tworsfeline2302 Před rokem

    I like that that CSS property now exists.
    ("that that" isn't a typo, it is weird grammar in English)

  • @rodbrowning
    @rodbrowning Před rokem

    I think this is the only video about this subject in the internet

  • @wahyusa
    @wahyusa Před rokem

    Cool !! 💯💯💯

  • @drenskywalker
    @drenskywalker Před rokem

    ✨ magic ✨

  • @aymanayman8209
    @aymanayman8209 Před rokem

    Sir, I would like to see you create a 2D intro with css, and by the way its because of you I loved css. Thank you for the amazing videos.

  • @ahmedharb88
    @ahmedharb88 Před rokem +5

    great explanation Kevin ♥
    so could you provide us a tutorial about : circular progress border using CSS

    • @KevinPowell
      @KevinPowell  Před rokem +4

      We could do something fun with that!

    • @ahmedharb88
      @ahmedharb88 Před rokem

      @@KevinPowell thanks a lot for that

  • @user-bg6zk3ly5v
    @user-bg6zk3ly5v Před 11 měsíci

    Hi Kevin, great video. I have a question, is it possible to do the last border and both sides?

  • @taneshpatel3051
    @taneshpatel3051 Před rokem

    Informative..

  • @octothorpe12
    @octothorpe12 Před rokem +1

    I've needed something akin to the radial gradient tip at the end, where you want something similar to 'mounting corners' in a photo album. Adjusting the stops to give a hard start to the transparency would be perfect!

  • @santhoshh4748
    @santhoshh4748 Před rokem

    These videos should be paid

  • @NIronwolf
    @NIronwolf Před rokem +3

    Here's a fun "highlight the corners" snip-it. Setup your own color and the transparent percents can tune how quick it fades out on each corner. The "to" keeps it pointed at the other corner if your container changes size.
    border: 0.3rem solid;
    border-image-source: linear-gradient(
    to bottom right,
    $color,
    transparent 30%,
    transparent 80%,
    darken($color, 10%)
    );
    border-image-slice: 1;

  • @clamhammer2463
    @clamhammer2463 Před rokem

    Could you use container queries to make slice more dynamic?

  • @cacowen
    @cacowen Před rokem

    Thanks for the video. Good stuff. Would this be a good use case for throwing a loading "spinner" on a button? I played around a bit and think the Gradient Example 2 approach with an animation altering the deg would make it look like a loading bar and perfect for a button. Throw the loading class on the button when it is clicked, and remove that class when the process is finished.

    • @crifox16
      @crifox16 Před rokem

      yeah that's what i was thinking too, especially with example three with a rotate animation

  • @Kawlinz
    @Kawlinz Před rokem

    4:24 - "I mucked up my bottom a little bit"
    I do that from time to time - it's fine

  • @estonian44
    @estonian44 Před rokem

    dang, u r wizard

  • @balubalaji9956
    @balubalaji9956 Před rokem

    wow nice.

  • @Jakiita1
    @Jakiita1 Před rokem

    I've been stuck trying to figure out an animated border-gradient with a Border radius while keeping a transparent background. I've seen ur animated border gradient video but with that method it looked like you need a 'background' for the card at the front to hide the gradient thats behind it.
    Is there a way to make an animated border with round corners? The SVG videos gave me the impression the gradient cannot be done in the CSS only in HTML, am I understanding that right?

  • @onnot701
    @onnot701 Před rokem +1

    I wonder if you design straight in css and hrml or still use figma?

  • @jameswrightson744
    @jameswrightson744 Před rokem

    Also known as a 9 slice on video games 🔥

  • @COLI_ALVAREZ
    @COLI_ALVAREZ Před rokem

    Hello! thanks for the video, very help full! which is the right size for an image not to pixel when using this property?

  • @sharkinahat
    @sharkinahat Před rokem +1

    Remember when border-radius wasn't a thing and everything had a gif border-image? Pepperidge farm remembers.

  • @Eleanor8965
    @Eleanor8965 Před rokem +1

    This was great! I am curious however on how you'd mix this with adding a border radius as well. It seems that the two "fight" one another.

    • @KevinPowell
      @KevinPowell  Před rokem +2

      Yeah it's one or the other with border-image :)

    • @Eleanor8965
      @Eleanor8965 Před rokem +1

      @@KevinPowell Thank you for this video and for your response. Also, I was the guy who emailed you last week about this very topic. This channel is awesome!

    • @captuhu
      @captuhu Před rokem +2

      right now if you want a round corner it would have to be included as part of the image. I have a github issue open with the CSSWG on making gradient border-image with work with border-radius.

  • @silasdaniel1850
    @silasdaniel1850 Před rokem

    useful

  • @MichaelWestcott
    @MichaelWestcott Před rokem

    Using border-image was pretty common before CSS3

  • @ev721
    @ev721 Před rokem

    Damn!

  • @tinguyen_dev
    @tinguyen_dev Před 6 měsíci

    How about the gradient border with radius? And transparent background also.

  • @MathGeekQ
    @MathGeekQ Před rokem

    nice

  • @realdev8940
    @realdev8940 Před rokem

    Can you please explain how it works for circular divs or images.

  • @murshid9033
    @murshid9033 Před rokem

    Can you do a video on animating gradient borders

  • @grasshopperweb
    @grasshopperweb Před 8 dny

    Just realized that I way overengineered gradient borders for my first client's website 😅

  • @rajarorauk
    @rajarorauk Před rokem

    This is brilliant, and very timely for a project I'm working on right now. However I'm struggling a little - I'm using a png with a design on a white background for border image, but my border seems to get a small gradient. I can't work out why or how to remove it. Any advice please?

    • @rajarorauk
      @rajarorauk Před rokem +1

      Don't worry. I fixed it. Only took 2 hours! The gradient was a box shadow from the div above. Obvs really.

  • @czerskip
    @czerskip Před rokem +1

    Lovely! 🎨
    Now, how about we combine images, gradients, clipping/blending and pseudoelements, and we get photo cutouts for borders… 🤔

    • @KevinPowell
      @KevinPowell  Před rokem +1

      I did it with cut corners and a gradient awhile back, you could probably use the same technique with an image - czcams.com/video/aW6qEAQSctY/video.html

  • @razorjhon2622
    @razorjhon2622 Před rokem

    how can we animate the linear gradient border , thank you for this i almost forgot how to use border and this video reminded me of it ^^

    • @KevinPowell
      @KevinPowell  Před rokem +2

      Because it's an image-source, just like a background-image, we can't animate it sadly. Or well, we could with @property and custom properties, but the support isn't very good.

    • @stephanvandermeijden289
      @stephanvandermeijden289 Před rokem

      @@KevinPowell Should be possible with JavaScript, right? Doesn't sound like a good idea, though.

  • @1985vicky
    @1985vicky Před 7 měsíci

    I tried. It works well except on table cells i.e. td element. Seeking explanation if possible. Love from India

  • @Rajendrakumar-zu4st
    @Rajendrakumar-zu4st Před rokem

    how to give border radius while using the linear gradient one?

  • @Kiev-en-3-jours
    @Kiev-en-3-jours Před rokem

    "The border property you never knew you needed"
    My negative side: "May be because we actually didn't need it?"
    My other side: "Just watch and shut up. You might actually happily use that one day".

  • @Gelo2000origami
    @Gelo2000origami Před rokem +2

    Watching you makes me want to ditch tailwind and just use css

  • @madameknees
    @madameknees Před rokem

    How does this interact with border-radius, and how many of these properties are animatable?

  • @mmuralikrishna2881
    @mmuralikrishna2881 Před rokem

    If am using border gradient doesn't support border radius. Any solution for this i dont want background-image gradient with border radius.

  • @SnehilCodes
    @SnehilCodes Před rokem

    Still looking forward to the day when border-image becomes compatible with border radius ;-;

  • @NotKyleChicago
    @NotKyleChicago Před rokem

    If you used "fill", would there be a lime green semicircle in the top left?

  • @irohwin4336
    @irohwin4336 Před rokem

    🗿❤️‍🔥

  • @VasilyPavlik
    @VasilyPavlik Před rokem

    Typing "Brilliant!!!" and start watching the video :)

  • @a_d_z_y__
    @a_d_z_y__ Před rokem

    I wonder how this would interact with border-radius though

  • @sheezanawaz476
    @sheezanawaz476 Před rokem

    How can I do the property of border-radius? when I give the border radius it effects the background color not linear-gradient border

    • @KevinPowell
      @KevinPowell  Před rokem

      No border radius with the images sadly, you'd have to set the corners of the image up to be rounded

    • @sheezanawaz476
      @sheezanawaz476 Před rokem

      @@KevinPowell but I am using linear gradient color for border, not image