Creating Custom Cursors - CSS Only, and JavaScript!

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

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

  • @bruneltommy5145
    @bruneltommy5145 5 лет назад +72

    For scrolling page
    css: transform: translate(-50%, -50%);position: fixed;
    js: cursor.setAttribute("style","top: "+(e.pageY - scrollY)+"px; left: "+(e.pageX)+"px")

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

      Pure luck we have you here. I just randomly checked comments a while after I put back my cursor project from my portfolio site since cursor leaves the hooked div while scrolling, then updated again when the cursor is moved. Caused div element to jump to the cursor after scroll. :/ So thanks :D

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

      You're a legend for this man

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

      Css transform translate is being ignored after adding the animation. Is there a way to keep the div centered to the mouse?

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

      @@sunkarasridhar3885 You need to substract half the height and half the width to your attribute (e.pageY - scrollY - Z), Z being half the height of your cursor

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

      @@KriszX12 thanx a lot , man!

  • @matther2012
    @matther2012 6 лет назад +131

    Hey Gary, great video. I really liked the animations there. One thing worth mentioning is that your implementation doesn't look like it takes into consideration that the cursor is always in the way of what you would be trying to click on like a link or something. Setting "pointer-events" to "none" on .cursor allows the cursor to be clicked through and would fix that issue.

    • @DesignCourse
      @DesignCourse  6 лет назад +6

      Yep, realized that when I put the codepen up!

    • @dhawalm
      @dhawalm 5 лет назад +9

      You just saved a life!

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

      @@DesignCourse Pin This Comment Gary! 😁😁😁

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

      I love

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

      Nice solution, but there's another issue, when it hover a link the "hand" cursor shows up, at least on my page, there's a way to fix this?

  • @DesignCourse
    @DesignCourse  6 лет назад +15

    Enjoy? Sub up! My answer for today's question: I think as long as it's kept *minimal*, and ideally still keeps the original cursor pointer around, it can work. It all depends on the context/purpose. You?

    • @Fliteska
      @Fliteska 6 лет назад

      I'd say no to custom cursors, being from the times of downloadable cursors it just brings back bad memories. I think the only time it would be good is a browser game like an old style rpg

    • @BrianSamThomas
      @BrianSamThomas 6 лет назад

      I say yes to customizing cursor! But it all does depend on the context. I'd want to (probably just for a personal project), maybe create a better svg of the original cursor (designed *for* the context) . And then give it some subtle transitions with minimal animations. Especially on something like all navigation elements. This would be to completely replace the original cursor, ofcourse. I mean, the more I think about it, the more the possibilities. Thank you for this introduction. #SweeetIndeed 17:48 🙌🏼

    • @ladyshh
      @ladyshh 5 лет назад

      I'd say it depends. If the site is for a designer/photographer/creative blog then the answer is yes (minimal as you say) otherwise the answer is no.

  • @premkumarh
    @premkumarh 6 лет назад +14

    It's midnight in India and I was prototyping my portfolio. Seems like I need to add this too I ain't gonna over do my website but I'm gonna add it for sure.. Loved it♥️

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

      whats your portfolio i wanna look at it, maybe get inspired too :)

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

    Thank you for this tutorial. I feel like I learned something because you were saying what you were doing and giving clear instructions. I'm not a fan of just copying directions with those silent tutorials so it was a relief to find your video. Thanks!

  • @AshishKumar-zi9gy
    @AshishKumar-zi9gy 6 лет назад +9

    really needed this one, was trying to figure it our with jquery coz i am handy with that.... love this one

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

    You deserve more than a million likes man !!!!

  • @6191jaken
    @6191jaken 6 лет назад +4

    I loved the tutorial. Has far as the question of customizing the cursor, my answer is that it depends on what you are doing. For instance, I may be developing a site for musicians. I can make the cursor into a note. Or, if I am working on a patriotic type of site, I can turn it into a flag. I see endless possibilities.

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

    Yess why not ? It looks so cool like you can see the idea of custom cursor adapted by some Devs in so cool way

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

    Cool. Just fyi, did not finish watching but have checked the codepen and I think it could be better.
    1. change cursor position: absolute -> fixed
    2. replace pageX / pageY with clientX / client Y
    Then it will act as a real cursor without moving during scrolling.

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

      @Rohan Kavathekar happy to help! : )

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

      thank you so much

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

    Such a great content especially for beginners. Thank you for this. Just keep these things up man. Fantastic job.

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

    Bro look so much like the protagonist of fight club. No wonder why you could produce such great content!

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

    Vừa vào đã nổi cả da gà 藍giọng a Phúc hayyy quá, mong sẽ tiếp tục cover ạ ❤️

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

    very useful! I used it to create a photo frame design. I like your efficient code, no one line wasted

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

    I saw many custom cursor tutorials yet end my search at your channel again.

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

    This may have a problem, when the user removes his cursor from the browser window the cursor stays at the edge...what can be the the solution to remove this issue ... Can we use the mouseout event in js

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

      use
      window.onmouseout = (e) =>{
      cursor.setAttribute("style", "display : none;")
      }

  • @gauravborra1
    @gauravborra1 6 лет назад +5

    Hi Gary, whenever i am searching how to video,next day you magically make video of that.
    Can you make video on preloading and prefetch contents of a website ??
    Anyways you are posting awesome stuff that i once think and say "how to do that" and now i am doing that.
    Thanks a TON for your videos

  • @arthurprather6720
    @arthurprather6720 6 лет назад +94

    Customizing the cursor, yes or no?
    For personal websites or portfolio sure why not. But for business, e-commerce, or professional websites, bad idea!

    • @christianachleitner9439
      @christianachleitner9439 6 лет назад

      why so?

    • @arthurprather6720
      @arthurprather6720 6 лет назад +23

      @@christianachleitner9439 Every pages have purpose or expectation for visitors. The goal for developers is to build a site that will get visitor to comeback and visit site again or refer other visitors to visit that site in the future so site can grow. If developer fail to meet expectation, then the site would become useless. For example, over animated page that require loading time, would turn off for most visitors who want to seek for quick information. I would recommend read good books - "Don't make me think" and "Design Everyday things". This will put better perceptive for most front-end designers/developers.

    • @RivenbladeS
      @RivenbladeS 5 лет назад +3

      @Hoyt Volker Well, in my opinion, if it perfectly fits the aesthetic of the website, it is professional and it gives a unique experience/feeling, it is very good and worth it.

    • @FirdavsiGameDev
      @FirdavsiGameDev 5 лет назад

      @@arthurprather6720 That was great explanation and thanks for recommending the books

    • @ThePixelitomedia
      @ThePixelitomedia 5 лет назад +1

      @@arthurprather6720 thats bs. Especially in advertising and design websites its a unique look and ux important...

  • @razenkellesly20
    @razenkellesly20 6 лет назад +1

    Man YOU ARE SUPER HERO bring more creative tutorials , what about line animation ?

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

    Hay this video is very exciting ! but I have single line on canvas and I want to change cursor to pointer as I hover over that line only. How can I achieve that?

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

    To centre the custom cursor to the default browser mouse you can get the absolute center by simply adding "transform: translate(-50%, -50%);" to the custom cursor css without doing any maths in the JS 👍

  • @karthikb.s8432
    @karthikb.s8432 3 года назад +1

    Thanks for the idea. I did this but got a problem, when I try to hover a div or click a div, the mouse pointer div comes in between so how to solve this problem. please help me.

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

    Chỉ cần Đức Phúc hát ballad thì dù buồn hay vui ĐP cũng truyền tải cảm xúc của bài hát rất tốt. Bài buồn thì nghe đúng kiểu tự sự, đau khổ, nghe là muốn khóc. Còn bài vui thì lại nhẹ nhàng, ấm áp, chân thành nghe là muốn yêu❤️

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

    Sugg: please use transformY and transformX instead top and left for smooth performance.
    Note* If using transform replace pageX and pageY to clientX and clientY.

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

    Very neat and scalable solution

  • @volodymyrberezovskyi6293
    @volodymyrberezovskyi6293 5 лет назад +1

    Thank you! Especially for mentioning pointer-events: none;

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

    I get an error Cannot read properties of null (reading 'setAttribute'). Cursor doesn't move with my mouse. Just stays static in upper left corner.

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

    This video has been helpful for me. Thank you so much.

  • @user-not-found-97
    @user-not-found-97 4 года назад +1

    Hey broo ... Successfully worked this same cursor, but this my container also moving up-down when i click on screen y??.. Please ... some help..

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

    Thank you, great tutorial, exactly what I was after!

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

    I created the cursor animation but now, the animation doesn't allow me to interact with my website components like the links and buttons.
    I also tried to change pointer-events to auto. Still no luck.
    The only fix I could arrive was is by letting the z-index stay at 0. Keeping it at 0 defeats the whole purpose of the cursor because it ends up hiding behind the dropdown menu and images.
    What am I doing wrong?

  • @joshkloomie1752
    @joshkloomie1752 5 лет назад

    In this implementation I'd say no, with different cursors that are context aware (like telling where to swipe, scroll or a call to action like buy or contact), yes. I think it would be possible to create such a thing from this, but since i'm not that good with javascript I'd have to try around a little bit to find out.

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

    Hi Gary, I thank you for the intersting lecture about customizing cursor. it was precise and very interesting. I have a question though. I wan to create a big crosshair which moves with mouse move, except that this crosshair is as big as my display window in the .html file. then i want the horizontal and vertical lines of the cross hair be the size of my display window. i also want the horizontal and vertical arms of crosshair move vertically and horizontally as i move curser up/down and left/right on the window. i also want to add a square in crossing point of this big crosshair and move on an image and capture a piece of the image for measurement of a physical phenomenan, do you have any idea how to go around this? thank in advance.🙏

  • @Rehan09able
    @Rehan09able 5 лет назад

    thanx for tutorial gary, u r always helpful for me.

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

    Will that really work to click links on the page tho? Since there is a div between the link and the actual cursor.... Anyway, If anyone have used this method for their site and noticed this problem it can be solved with pointer-events:none; in css. That allows you to click through a div

  • @valix85
    @valix85 6 лет назад +1

    Very cool, yes customize it all!

  • @Malaloeil
    @Malaloeil 5 лет назад +2

    Hi Gary,
    is it possible to change the cursor but not to the entire , but just a div for example, so i can use multiples cursor in different places for example ? How would you do that to choose a class div with your code?

    • @Alex_192.
      @Alex_192. Год назад +1

      you can just put the cursor thing into .className instead of body in CSS

  • @abhijithchandran5744
    @abhijithchandran5744 6 лет назад +12

    Hi bro, can you make video about three. Js. And thanks for this amazing video

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

    Great! But how i add a trail to the animation?

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

    a new sub. It´s amazing

  • @tchackeg9370
    @tchackeg9370 5 лет назад +1

    How to get this cursor in your whole page , i can only get it at the home page, when i scroll it goes away.

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

    wow this is so good!
    How can I make the hover effect?
    when hovering over an object and doing an effect on hover
    I would appreciate if you help me
    bye friend

  • @razenkellesly20
    @razenkellesly20 6 лет назад

    YES new designs LOVES it.

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

    yes bacause of this cursor are very good for UX thats why this is amezing .....

  • @jaxxbird7
    @jaxxbird7 5 лет назад

    Such a good Tutorial! Thank you so much!

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

    Hello. My query in which part of my wordpress to paste the css code to animate the cursor. Thanks

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

    hey! i was making a whiteboard projecct i want the cursor to look like prncil when i select pencil , etc please teell me how can i do it.............
    '

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

    When i scroll down page with middle mouse button or press buttons on header, page scrolling down as it's supposed to be, but that custom cursor stays where it is until i move again mouse. So above or under sections. I used codes from codepen. What is the problem? when i do that;
    html {
    height:100%
    overflow: hidden;
    }
    body {
    height: 100%;
    overflow-y: scroll;
    overflow-x: hidden;
    }
    This problem is solved. But it causes a few undesirable situations in other elements. Is there another option to solve this?

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

    I am using this in react but after adding mousemove event click events are not working some help please

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

    What are the extensions that you have manually downloaded sir

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

    my cursor is notshowing smooth transition seems like it shows a bit of lag i.e it does not seem to be synchronized

  • @yanmezinskiy8817
    @yanmezinskiy8817 6 лет назад

    This is really cool tutorial :) Thank you a lot

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

    I really appreciate your video, and I have a question, can you share with us how to hide the cursor in mobile mode? Thanks again!

  • @Godsavethecrumpets
    @Godsavethecrumpets 5 лет назад +2

    im having a problem where the custom cursor isnt registering clicks any ideas?

    • @JohnDoe-sz5jh
      @JohnDoe-sz5jh 5 лет назад

      I am having the same problem.

    • @sunjungwoo
      @sunjungwoo 5 лет назад +1

      @@JohnDoe-sz5jh It's late but set pointer-events: none; to .cursor class.

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

    will you make a video that teaches how to use custom cursor svg's for hover and click?

  • @aslambekeskhadzhiev1414
    @aslambekeskhadzhiev1414 5 лет назад +3

    Is this possible with WordPress? Looks great!

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

      yes the method is the same , no extra twitch is necessary

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

    Hello sir would it be possible to make a laser line that follows the cursor revolving around the center of screen?

  • @praveenkumar-cn1gf
    @praveenkumar-cn1gf 3 года назад

    can anyone answer this, I want to change the cursor style properties when hovering any link in the web page .

  • @armandsalle8447
    @armandsalle8447 6 лет назад

    Really great video ! Hello from France

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

    TypeError: Cannot read property 'setAttribute' of null

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

    I've tried it on a WordPress site, but it didn't work.

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

    my website is styled in css, can I just copy paste the css into the scss or does that not work?

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

    It's very very good and useful. Thanks for the informations.😃

  • @TiimedArts
    @TiimedArts 5 лет назад

    can you also use it on the desktop???

  • @The-Biker-Bites
    @The-Biker-Bites 6 лет назад

    will do it definitely

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

    I copied your code and the cursor does not move smoothly like yours, it lags, jumps from one point to another, transition is set

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

    is there a way to make this without SCSS?

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

    I love yout tutorial u are my inspiration thank u so much from Angola/Luanda....

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

    Guys, Css transform translate(-50%,-50%) is being ignored after adding the scale animation. Is there a way to keep the div centered to the mouse and scale the div?

  • @joezerodi3836
    @joezerodi3836 5 лет назад

    any tips on how to follow the mouse when scrolling? for me the circle freezes in place until im finished scrolling.

  • @jaccunningham
    @jaccunningham 10 месяцев назад

    You mentioned there was a CSS only code. I added the CSS but it is not working. Is there another step? Hoping you still reply to this video :)

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

    Thank you this is insightful

  • @mohammadvahedi78
    @mohammadvahedi78 5 лет назад

    thanks buddy for this amazing video ;)

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

    my mouse follower lags a little and sometimes it lags very much , any solutions??

  • @franktielemans6624
    @franktielemans6624 6 лет назад

    how can i make the custom cursor only appear when I hover over some specific area (div)?

    • @akaizn
      @akaizn 6 лет назад

      I'm spitbaling here but you can make the cursor element a child of the element you want it to appear in, change the cursor's position to relative hide it and display it on the parent's hover

  • @Amitkumar-zp3wb
    @Amitkumar-zp3wb 4 года назад

    The Cursor was made fine but now it's not clicking or selecting anything, I guess it is overlapping the actual cursor. How do I fix this?

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

    would mind helping me by making another video on how to prevent mouse cursor not go out of the body of the web page which may be useful on a systems like online exam system please

  •  Год назад

    This is not working for me, could someone explain to me how this could be added to wordpress? The codes don't work there. what a disgrace

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

      not working for me in vs

  • @vishnumenaria2581
    @vishnumenaria2581 5 лет назад

    How to custom cursor use in paint/ one note2017 plz help

  • @Merko2
    @Merko2 6 лет назад

    For a normal webpage, you probably won't do it. But i think there's some cool cases where you can use custom animated cursor like these for some cool stuff :) (Other than gaming).
    Great tutorial!

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

    how can i get the same design in wordpress

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

    i feel like his voice is similar to the rat character Remy in Ratatouille Disney movie. Its cool!!

  • @puneetkumar6
    @puneetkumar6 6 лет назад

    Love your videos 🤘

  • @frerosami7
    @frerosami7 6 лет назад

    I think that customize cursor is a great idea.

  • @ManikMia-qv8oy
    @ManikMia-qv8oy 4 года назад

    Great Stuff!!!

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

    I NEED HELP, WHEN I TRY TO SEE THE WEBSITE, IT REMAINS WHITE. CAN YOU TELL ME WHY? THANK YOU

  • @thienwinchester
    @thienwinchester 5 лет назад

    I implemented this for my portfolio, but it seems there is a problem with the button on form submit, It looks like it prevents the form submit button from being clicked. I even add pointer-events: none; to the cursor, but it still doesnt work for the button type="submit"

    • @webstreak9634
      @webstreak9634 5 лет назад

      I have a similar problem my pointer wont click on the anchor tags.

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

    I have a question. What font-size are you using?

  • @demonsahil7841
    @demonsahil7841 10 месяцев назад

    thank u buddy, u helped a alot

  • @RSTao77432
    @RSTao77432 5 лет назад

    do you know how to get .ani custom animated cursors to work, have tried this several times but never ends up working, annoying coz there some really cool sci-fi style cursors that would look awesome on phaser games etc

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

    Is it possible to integrate this CSS/html script into Windows mouse settings itself, such as permanently changing your mouse cursor? Thanks.

  • @thallamrithesh6763
    @thallamrithesh6763 6 лет назад

    it is a great idea.
    thanks for such a good videos

  • @glebeezus4934
    @glebeezus4934 5 лет назад

    hi everyone! please help me! i put my custom cursor on my page and i have a problem, i can't click on any link. It works while the circle goes to mouse, but when they both together, a link is not clickable. thx!

  • @draemcast2000
    @draemcast2000 5 лет назад

    How would I do this on Neocities?

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

    how to add to my Wordpress template?

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

    Anyone know how to add particles falling or coming from the cursor?

  • @حيدرنوريطالب
    @حيدرنوريطالب 3 года назад +1

    Thanks Very Mach For This Video

  • @RumenGeorgieff
    @RumenGeorgieff 5 лет назад

    Hi, how can I make it not pulsing .. just a circle :)

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

    How this code work while the div have a class of cursor and not an id of cursor

  • @njanadesign
    @njanadesign 5 лет назад

    how can i implement this into a Wordpress website (am using a purchased theme)?
    is it possible?