How To Make Tooltips With Only CSS

Поделиться
HTML-код
  • Опубликовано: 30 мар 2020
  • 🚨 IMPORTANT:
    Learn CSS Today Course:courses.webdevsimplified.com/...
    Tooltips are practically essential to any web site now, but making them can be pretty complex. You may think you either need to write a bunch of JavaScript or turn to a complex tooltip library, but with just plain CSS you can create really interesting animated tooltips. In this video I walk through the exact steps needed in order to create highly customizable CSS only tooltips that can have dynamic and custom content in them.
    📚 Materials/References:
    GitHub Code: github.com/WebDevSimplified/C...
    CodePen Code: codepen.io/WebDevSimplified/p...
    CSS Variables Tutorial: • CSS Variables Tutorial
    CSS Triangles Blog Post: blog.webdevsimplified.com/202...
    🧠 Concepts Covered:
    - How to create triangles in CSS
    - How to use transform/translate with animations
    - Using data attributes in CSS
    🌎 Find Me Here:
    My Blog: blog.webdevsimplified.com
    My Courses: courses.webdevsimplified.com
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/WebDevSimplified
    CodePen: codepen.io/WebDevSimplified
    #Tooltip #WDS #CSS

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

  • @BribedStudios
    @BribedStudios 4 года назад +45

    Just bought the course - haven't been hyped for something like this in a long time! Great videos, keep it up, Kyle!

    • @WebDevSimplified
      @WebDevSimplified  4 года назад +5

      Thank you so much! It really means a lot.

    • @maskman4821
      @maskman4821 4 года назад

      Kyle is really good at teaching/explain complicated thing, though the tooltip is just a small component, it takes a lot of code to accomplish. Without good teacher's leading most people go for library or framework !!!

  • @ScileSc
    @ScileSc 4 года назад +1

    Good job as always. This is exactly what I did a week ago. One tip: You can also select elements by attribute in css, so you can slap the attribute on pretty much every non self closing element and it just works.

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

    Hey Kyle, I really enjoyed this one and during this challenge my understanding of some concepts got more clear. Thank you man!!

  • @user-rl1ki6bk9f
    @user-rl1ki6bk9f 4 года назад +4

    🙏🏽thank you! This is such a useful css skill which I’ve never used before!

  • @ephremgetachew6975
    @ephremgetachew6975 Год назад +1

    You are honestly TALENTED. It literally just flowed into my brain. the way you explained it is just PERFECT. Thanks Man.

  • @thatoneuser8600
    @thatoneuser8600 4 года назад +13

    Oh cool, was just learning about CSS variables and was wondering why you'd use them, but the end of the video is a great example of why. Thanks as always!

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

    Oh my god, this is incredible! Thank you SO much! No more suffering with trying to code tooltips in JS!

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

    Excellent. This is what you can do with deep knowledge of the inner workings of CSS. Yes, it's a lot of code, but each bit is doing something, and understanding each bit gives you another tool you can use somewhere else.
    Took me a bit to figure out the border triangle. I was thinking rotation, but if you don't have to, less is better.

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

    Kyle, I appreciate you man. Thanks for this lesson. I did check your blog post on the CSS triangle. It was really informative and helpful. Big ups to you bro. God bless you. You are doing great. ✌️❤️

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

    Hey, that's awesome. Thanks for sharing!

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

    Didn't know the concept of triangles before. Thank you so much.
    ✨✨

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

    Very informative and what's more: straight to the point, which iscrare on youtube nowadays.
    Probably no coincidence the ads interrupting this video are from Whiskas

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

    thanks ..... i was needing this soo much...

  • @foxracing19x
    @foxracing19x 4 года назад

    Thank you! Keep up the good work 👍🏻

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

    This is wonderful, thank you so much!

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

    This is some intense CSS! WOW!

  • @bunnybloods768
    @bunnybloods768 4 года назад +1

    Omg! I have been waiting for you videos since quarentine.

    • @WebDevSimplified
      @WebDevSimplified  4 года назад +1

      Hopefully I can make being stuck at home a bit better.

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

    This was a great tip. Thanks. :)

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

    Very helpful video, thank you so much!

  • @cyberneophyte3847
    @cyberneophyte3847 4 года назад

    Awesome tutorial as always dude... It's a buttload of code for a simple tool tip.. but at the end of the day cant argue it's well worth it!.. Ty

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

    Incredible tips, thanks a lot

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

    omg... thank u so much buddy... I subscribed your channel... keep it up... sending you a lots of love...

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

    Saved my day😍you're awesome😍😍Thank you ❤️

  • @fluffydoggo
    @fluffydoggo 4 года назад

    Thanks kyle for a once again great tutorial

  • @abdolahkeshtkar4672
    @abdolahkeshtkar4672 4 года назад +1

    you are really awesome mannn, you helped me a lot with my css and your voiiiiccceee is soooo nice, wish you the best

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

    I love yor channel, I'm a developer from Argentina, your videos are so usefull to me, thanks!

  • @soniablanche5672
    @soniablanche5672 4 года назад +1

    Wow I actually learned something new

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

    You are just Awesome brother :)

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

    great vids appreciated! would be cool to see a vid of you explaining your background, like when you got into code how long you've been doing it why u did it etc etc. just nice to have the inspiration sometimes to see peoples stories

  • @HossamKhalaf-sr1oo
    @HossamKhalaf-sr1oo 4 года назад

    thanks for the great work!! wish that i won the course.. needed badly

  • @shekhsaifuddin1353
    @shekhsaifuddin1353 4 года назад

    You are just awesome brother 💕💕💕

  • @Helen-mu2yv
    @Helen-mu2yv 2 года назад

    Thank you so much!

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

    Ty bro a lot you save my time :)

  • @RubenMartinez-qp2gg
    @RubenMartinez-qp2gg Год назад

    you are awsome and a good teacher, thanks

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

    I learnt a lot of other things, instead of just tooltips.

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

    Thanks very much, what if you want to set the direction of the tooltip, cos sometime it goes out of the screen considering the fact that the div is at the top of the screen

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

    Would take me weeks to figure out without this tutorial.

  • @tim_t
    @tim_t 4 года назад +42

    I just add a "title" attribute to the HTML and call it a day. 😂

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

    A stealth tutorial on the usefulness of CSS variables

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

    Great video as always, love the way you teach, its awesome. There is one thing to catch and its since the position is absolute the tooltip is shown within its parent and goes behind other elements which is not desirable and as long as I change the position to Fixed it doesn't work. Its appreciated if comment it out

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

    Hi, Kyle, thanks for all the good video's.
    I have been trying to do a CSS only Tooltip for a while now. And with each solution on the web, including yours, is that when the tooltip get's to big and go's off screen i see some dark bars at the bottom of the screen.
    I love to have the tooltip switch position based on the location where it wants to been shown. Like when the tooltip starts to far to the left (outside the screen) it will always move to the right same for when the width is to large so the tooltip is going outside the screen.
    For the vertical positioning, when there is no space on top of the element it should show itself below the element.
    I know there are some JS scripts doing that but can it somehow been done in modern CSS ?

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

      sorry I don't have answer according to your need
      but you can set overflow: hidden for the body tag at the start of the CSS
      these will remove the bottom scroll bar

  • @MaxProgramming
    @MaxProgramming 4 года назад +4

    Thank you so much sir. Needed it. One suggestion. You can enable autosave from File>Autosave to see the live preview faster and avoid saving.

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

      I actually like having control over when I save so I can emphasize specific groups of changes.

    • @MaxProgramming
      @MaxProgramming 4 года назад +1

      No problem that's fine. Thnks a lot for this one. BTW, do you have a discord server? I want to join as much as I can

    • @WebDevSimplified
      @WebDevSimplified  4 года назад +1

      I do. It is linked in the description.

    • @MaxProgramming
      @MaxProgramming 4 года назад +1

      @@WebDevSimplified Thanks a lot

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

    i just figured using data attributes in css has so many use cases....... thank you very much.

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

    thank you so much bro

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

    Great tutorial. I was working on a tooltip today, but messed up. I'll try again tomorrow with the help of this tutorial.
    Question relating to Visual Studio Code: how do you get the background to not show your desktop? I set mine to show it, but I don't want it now lol. It's hard to see everything.

  • @user-um4zm9np7c
    @user-um4zm9np7c 10 месяцев назад

    video is the best it is useful thank you

  • @marizzlleable
    @marizzlleable 4 года назад +1

    Just subbed to your CSS course 👍

  • @alissonpratesperes6077
    @alissonpratesperes6077 4 года назад

    Awesome! But, do you know how I can add the property "backdrop-filter" on the tooltip, is this possible ? I would like the blur effect on the background of the text...

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

    This is the best tutorial I've seen in months! Thanks! Will be checking out your course, soon. How can I replicate this for 6 items, though without having to copy all of that over 6 times and give it a new class name?

  • @johncerpa3782
    @johncerpa3782 4 года назад

    Great video

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

    Well, yes. But add detection of when there is no room to show the tool tip north of the trigger, and display it south. While it can't be done in CSS (because there is no selector for "not all of this rectangle is visible", the challenge is to do it with a minimal amount of JavaScript code.

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

    Hi Kyle. I'm stuck in my tooltip tutorial that I have just followed in your video here. My image does not show up :(. I don't know what happened.

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

    Does anyone know to style text like addding or in data-tooltip? I've read something related to BS.

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

    Hi Kiel.Very good tutorial.But I am encountering one problem here.when I reduce the size of the screen the tooltip moves away from it's central position of the object .I mean it is before when screen enters tablet or mobile pixels.Can you give tip how to figure out this issue.Thanks.

  • @soumelee5661
    @soumelee5661 3 месяца назад

    amazing video

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

    You're a god among men, thanks!

  • @vvvideo0
    @vvvideo0 4 года назад

    Amazing~

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

    I'm new in WebDev and still learning it, so I wonder what is the point of using the tooltip? What's the difference if we do it like e.g. content: attr(data-tooltip), or we just simply do content:'Thinking cat''; (What is the point in using data- attributes if we aren't making carousel for example). Thanks in advance!

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

    Great vid, can i use a tooltip also for tables?

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

    Great explanation! I was wondering if anyone knows how to do the exact same thing, but with a border or a shadow around the entire tooltip? Other tutorials suggest adding a second triangle for the border using the ::after pseudo-element, but in this tutorial we're already using both the ::before and ::after

  • @cancer10in
    @cancer10in 4 года назад +1

    If the tooltip has a lengthy string, then the box scales vertically instead of horizontally. How to fix this?

  • @ZeeshanAhmad-lq5nc
    @ZeeshanAhmad-lq5nc 4 года назад

    can we reference other html element in other element with attribute and use it with js or css, if can how to do it, because i have seen in many websites to do that.

  • @incrediblefman8126
    @incrediblefman8126 4 года назад

    I love your videos

  • @forgiveness_denied
    @forgiveness_denied 4 года назад +8

    14:23 there’s still visible 1px gap between them 😂 maybe just move that arrow up few pix, it’s not noticeable on green color

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

    Thanks!

  • @WebDevdai
    @WebDevdai 4 года назад

    thanks you

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

    thnaks bro

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

    Hi Kyle, how to change the tooltip position dynamically (current it is top if i want to show at bottom , left or right)

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

    do you know why the hover grow animation is bumpy and the uncover shrink animation is smooth? im using safari

  • @Kiran-lr8gi
    @Kiran-lr8gi 2 года назад

    For tooltip dynamic positioning, we need javascript right?

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

    Does this apply for long text as well?

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

    DIOS TE BENDIGA, Gracias por compartir tus conocimientos

  • @ZeeshanAhmad-lq5nc
    @ZeeshanAhmad-lq5nc 4 года назад

    in ::after and ::before % which refers to, is itself or just .tooltip?

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

    what does the
    *, *::before, *::after {
    box-sizing: border-box;
    }
    rule do?

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

    Thank you for this. Can you do a video about plotting data using HTML CSS?

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

    8:20 this CSS variable support all browsers? I'm confused how to make this variable? it should be from a " :root " right?

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

    When I have elements underneath the tooltip that have a z-index greater than 0, the tooltip sits underneath the element. Changing the z-index of the tooltip itself doesn't fix this. Any idea why this is happening?

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

    Does work for input text as well?

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

    Hi, can you please make some video on the tooltip card which will work exactly like the google map tooltip card on hovering on the location.
    Thanks,

  • @Dedseq
    @Dedseq 4 года назад

    How would you fix when the hover area is bigger than the element. In this case, the cat photo?

  • @anthonysim563
    @anthonysim563 Год назад +1

    Why are we selecting both ::before and ::after?

  • @rangabharath4253
    @rangabharath4253 4 года назад

    Awesome

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

    how to set the position of tooltip right left top or bottom?

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

    Maybe silly question, but how can I put a a href only on the textbubble?

  • @Stephane_
    @Stephane_ 4 года назад

    Which extension do you use for the live preview? I used to code with "Live Server" but it never works...

    • @ScileSc
      @ScileSc 4 года назад

      When you look at the bottom bar of VSC you can see that he is using live server. Does the extension throw an error for you or does it just refuse to reload?

    • @Stephane_
      @Stephane_ 4 года назад

      @@ScileSc It's been a while so I honestly don't remember what was the issue. I think it just stopped reloading the page with no reason.

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

    It happens to me that the tooltip shows up when the tooltip itself is hovered. Any clue on how to solve that? Much appreciated!:) Greate tut btw

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

    It doesn't work when you have to deal with overflow: hidden in parent element. The tooltip gets clipped if the parent has overflow: hidden. If there is a workaround for it. Pls let me know

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

    Cool lesson, but how to insert HTML code inside the data-tooltip attribute to style a multiline tooltip?

  • @zvit
    @zvit 4 года назад

    We already sent people to the moon but in 2020 we still need a 15-minute tutorial and a whole bunch of code to make a simple tooltip.

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

    I want the same tooltip but on right direction how can I do that?

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

    Its crazy how much work the frontend devs have to do to for such a small component

  • @Programming-Fun-With-Hima
    @Programming-Fun-With-Hima 4 года назад

    You're always special

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

    can I use the tooltip on the button to display the message

  • @KsanterX
    @KsanterX 4 года назад

    Haha, I was just thinking about it. I didn't want to use Bootstrap's solution because it requires a separate JS library.

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

    Hi Kyle, Do you have already created a video for a tooltip text to be clicked like here the text say "Thinking cat", I want to click on that text and it opens a new window. That's it.

  • @rudi-batubara
    @rudi-batubara 9 месяцев назад

    Tooltip flow clue: 1. Create a tooltip wrapper by fragment, so we do add addition element on it, 2. initialize a child component thought cloneElement and attach a ref on it, 3. add a tooltip element with a forward ref and add it to wrapper by a portal, attatch a mouse and leave event handler to any child element thougt clone element same as we did before for ref on child component, 4. Get bounds of child component X and Y coordinate, passing this coordinate to tooltips component thought style attribute. 5. End...

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

    Hi good video 👍 but
    What is the difference between Tooltip and Hotspot??? 🤔
    I would appreciate your answer

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

    7:27 I set max width to 100% but my text still overflowing.. can someone tell me why? :(

  • @Marcus_YT.
    @Marcus_YT. 2 года назад

    how do I make it individually?

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

    I'm seeing a gap between the triangle and the circle. How can I get rid of it?