Css Custom Animated Checkbox - How to make CSS switch / toggle / custom checkbox - No Javascript

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ก.พ. 2025

ความคิดเห็น • 110

  • @daylinjones7194
    @daylinjones7194 4 ปีที่แล้ว +1

    THANK YOU!!! for breaking this down step by step. Didn't realize Wordpress was overriding my styling until I saw this video. Very GRATEFUL!!!

  • @Coding_Tricks771
    @Coding_Tricks771 11 หลายเดือนก่อน +1

    Thank you very much this help me lot

  • @Funnycreature17
    @Funnycreature17 5 ปีที่แล้ว +20

    Tags that don't close ( in this case) can't have pseudoelements. Although this might work in modern browsers, this is not a valid way to do it and won't work properly in IE11 for example. You gotta use ::before and ::after of the parent div (or label) instead.

    • @reallygood7580
      @reallygood7580 4 ปีที่แล้ว

      this should get more likes, because its true

    • @MrHouloul
      @MrHouloul 2 ปีที่แล้ว

      can you write it I dont understand

    • @Funnycreature17
      @Funnycreature17 2 ปีที่แล้ว +7

      @@MrHouloul Ok I'll try.
      The markup in this tutorial is
      ...

      ...
      what I suggest doing instead is:
      ...



      ...
      Then you can hide actual input like this:
      .hidden-input-part:not(:focus):not(:active) {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      overflow: hidden;
      border: 0;
      clip: rect(0 0 0 0);
      }
      and change selectors from this video like this:
      input[type="checkbox"] ---> .hidden-input-part + .visible-input-part
      input:checked [type="checkbox"]---> .hidden-input-part:checked + .visible-input-part
      input[type="checkbox"]::before ---> .hidden-input-part + .visible-input-part::before
      input:checked[type="checkbox"]::before ---> .hidden-input-part:checked + .visible-input-part::before
      There are like 5 more way to do this correctly that I know about, this one is just my go-to method.

  • @zholy9
    @zholy9 6 ปีที่แล้ว +2

    Just tried it today and managed to make it work. Line 46 (left:40px) on the "checked::before" didn't work for me with SMOOTH animation/transition = had to use TRANSLATE(100%). When I've left it like you have, for some reason the transition didn't "kick in" and the change of the button position was instant, rather then smooth/animated.
    BUT ... still - awesome job on this one. With such "styled checkbox" and SIBLING COMBINATOR I've managed to do a nice option between MONTHLY/YEARLY pricing tables ...

  • @2323m-d9b
    @2323m-d9b 2 ปีที่แล้ว +1

    i wanna steal your skills

  • @Edthewebsurfer
    @Edthewebsurfer 5 ปีที่แล้ว +4

    Simple and to the point, thank you for uploading.

  • @DcodeShow
    @DcodeShow 4 ปีที่แล้ว +3

    Wow, you are the man, this is an incredible use of inputs. Thank you for sharing.

  • @nicolaszarate2439
    @nicolaszarate2439 3 ปีที่แล้ว +2

    Thanks a lot. This tutorial was so helpful for a project.

  • @reallygood7580
    @reallygood7580 4 ปีที่แล้ว +2

    Win + Tab. Nice...

  • @RenardBellini
    @RenardBellini 2 ปีที่แล้ว +1

    Thank you! You're the best css player hehe

  • @gyros9162
    @gyros9162 ปีที่แล้ว +1

    this is cool and beautiful

  • @leonardocamargo5412
    @leonardocamargo5412 4 ปีที่แล้ว +4

    Melhor vídeo sobre o assunto não pode existir xD. Muito simples de se fazer, as pausas no codigo para mostrar como está ficando são muito boas para o aprendizado. Parabéns pelo trabalho!!!

  • @revanth9272
    @revanth9272 4 ปีที่แล้ว +1

    I learnt a lot from you👍.

  • @animartesketch
    @animartesketch 3 ปีที่แล้ว +1

    however if you create more than one button it generates a bug the little ball of the second or third button goes to the place where the first switch is, it only works if it is with only 1 button

  • @Ibrahimkhalil-hw4hd
    @Ibrahimkhalil-hw4hd 3 ปีที่แล้ว +1

    Thank you bro. You are amazing

  • @ldawg214
    @ldawg214 7 ปีที่แล้ว +19

    You should add comments to your code so viewers can get an idea of what you're doing. For example, the center class is only for your tutorial and is not needed in a real project. Unless the checkbox needs to be in the center of the screen. Other than that, I get a ton of ideas from you. Keep it up.

  • @gauravdewangan1460
    @gauravdewangan1460 3 ปีที่แล้ว +1

    Thanks man. Good tutorial but also add comments in code for beginners

  • @Jamesis07
    @Jamesis07 3 ปีที่แล้ว +1

    Thank you very much you are perfect

  • @satyabratasahoo8665
    @satyabratasahoo8665 4 ปีที่แล้ว +1

    Very nice 👌

  • @NinjaCoders
    @NinjaCoders 3 ปีที่แล้ว +1

    thank you bhai

  • @sujandrn6186
    @sujandrn6186 4 ปีที่แล้ว +4

    i really love it......

  • @iliasselaissi3890
    @iliasselaissi3890 3 ปีที่แล้ว +1

    this is the easy way to do it

  • @emre-vt6zi
    @emre-vt6zi 3 ปีที่แล้ว +1

    thank you..

  • @ismotarasrity4696
    @ismotarasrity4696 4 ปีที่แล้ว +2

    Thanks

  • @martinflores9611
    @martinflores9611 6 ปีที่แล้ว +1

    your video
    It helped me a lot

  • @DeshanUdupihilla
    @DeshanUdupihilla 4 ปีที่แล้ว +1

    a perfect video. thank you very much! ♥️

  • @The_EpicVoice
    @The_EpicVoice 7 ปีที่แล้ว +2

    that's fantastic keep going!! if u add ur voice it would be better

  • @miriaandressa2734
    @miriaandressa2734 3 ปีที่แล้ว +1

    Nice, thanks

  • @Error-zs1yn
    @Error-zs1yn 4 ปีที่แล้ว +1

    thank you so much

  • @AdairAconzs
    @AdairAconzs 4 ปีที่แล้ว +1

    Nice

  • @nomanabid9394
    @nomanabid9394 4 ปีที่แล้ว +1

    You're the BEST

  • @edoBianchi
    @edoBianchi 3 ปีที่แล้ว +1

    good.thx

  • @eypbal
    @eypbal 7 ปีที่แล้ว +7

    This is so perfect. Thanksssss

  • @vincenzocristiano135
    @vincenzocristiano135 2 ปีที่แล้ว +1

    thanks legend!

  • @emcasaempreendimentosimobi3229
    @emcasaempreendimentosimobi3229 4 ปีที่แล้ว +1

    Perfect . Thank you

  • @christianromero6815
    @christianromero6815 2 ปีที่แล้ว +1

    How to do this with input{ all: unset;} in reset stylesheet???

  • @princeyadav4294
    @princeyadav4294 2 ปีที่แล้ว +1

    great

  • @CoderDmitri
    @CoderDmitri 4 ปีที่แล้ว +1

    ty

  • @aliabukahil
    @aliabukahil 3 ปีที่แล้ว +1

    Absolutely appreciated

  • @emanueldiazmx
    @emanueldiazmx 6 ปีที่แล้ว +1

    Wow thank you so much, its so nice and easy to code. Really awesome!

  • @kikiriki2024
    @kikiriki2024 3 ปีที่แล้ว +1

    Gracias

  • @alonsogza2890
    @alonsogza2890 7 ปีที่แล้ว +3

    Muchas Gracias, Excelente ejemplo

  • @xaxa730
    @xaxa730 6 ปีที่แล้ว +5

    What if I applied a delay to the input to turn blue only when the white circle touched the other end? 🤔

  • @jaspreethayer2275
    @jaspreethayer2275 5 ปีที่แล้ว +2

    Amazing

  • @luiza4142
    @luiza4142 7 ปีที่แล้ว +1

    You save me again thx bro

  • @letsfly662
    @letsfly662 3 ปีที่แล้ว +1

    What should do if you have multiple checkboxes but you only want one to be like this? i.e. how do you make a checkbox unique?

  • @vijaygohil4685
    @vijaygohil4685 7 ปีที่แล้ว +3

    You have created the videos is very best or superb but I request that enter voice in your video and explain case property SVG

  • @grinders2000
    @grinders2000 2 ปีที่แล้ว +1

    THANK U

  • @amine_ers
    @amine_ers 4 ปีที่แล้ว +1

    Thaaanks

  • @ProMakerDev
    @ProMakerDev 5 ปีที่แล้ว +1

    thank you very much, such a great help

  • @micromanBD
    @micromanBD 6 ปีที่แล้ว +1

    So many thanks for sharing it.

  • @Peter_Gamerrr
    @Peter_Gamerrr 5 ปีที่แล้ว +2

    you should use :: for pseudo elements instead of using : because that's for pseudo classes pls I know just a single one works to make sure its backwards compatible but it's not the default for css3

  • @tonnichowdhury7356
    @tonnichowdhury7356 4 ปีที่แล้ว +1

    thanksssss aaa trillion

  • @AruljothySundramoorthy
    @AruljothySundramoorthy 4 ปีที่แล้ว +1

    Awesome Man

  • @edwingarcia5043
    @edwingarcia5043 5 ปีที่แล้ว +1

    Awesome bro

  • @deepaksarvepalli2344
    @deepaksarvepalli2344 4 ปีที่แล้ว +2

    I couldn't able to change width and Height with differente pixels.... Means it took only same value for the dimensions... Like square.... Please help me to fix this...

  • @rainchai851
    @rainchai851 5 ปีที่แล้ว +1

    i prefer this song

  • @wilsommontec390
    @wilsommontec390 5 ปีที่แล้ว +1

    Me sirvio su video gracias

  • @syediqbalahmed3176
    @syediqbalahmed3176 5 ปีที่แล้ว +1

    *_good_*

  • @PramitBiswas
    @PramitBiswas 6 ปีที่แล้ว +1

    How to add dragging and snapping functionality along with click with js and css only?

  • @maazsiddiqui6324
    @maazsiddiqui6324 4 ปีที่แล้ว +1

    my button which is scaled gets small when its checked and when cheked it scales(1.1)! solution?

  • @alexkotusenko302
    @alexkotusenko302 7 ปีที่แล้ว +3

    NICE!!!!!!!!!!!!!!!!!!!!!! LIKE!!!!!!!!!!!!!!!!!!!!!!

  • @tsnode4098
    @tsnode4098 5 ปีที่แล้ว +1

    thaks for this

  • @NadeemJohn-xu4lu
    @NadeemJohn-xu4lu ปีที่แล้ว +1

    NADEEMJOHN

  • @bobsuk777
    @bobsuk777 7 ปีที่แล้ว +3

    God stuff, but, in input[type='checkbox'] css declaration, must be added -moz-apearance:none; for firefox compatibility

    • @postamble
      @postamble 6 ปีที่แล้ว +2

      Bob Suk yeah and a display:none on the checkbox element would be way better

    • @reallygood7580
      @reallygood7580 4 ปีที่แล้ว

      @@postamble TRUE

  • @justb3m184
    @justb3m184 3 ปีที่แล้ว +1

    Salute!

  • @hvxun9924
    @hvxun9924 4 ปีที่แล้ว +1

    amazinggggggggggg

  • @guylemay1471
    @guylemay1471 5 ปีที่แล้ว +2

    Yeah... this is more like it! It is good enough that it would probably make a JS Guru noticed your Kung Fu?

  • @cypherk
    @cypherk 4 ปีที่แล้ว +2

    Doesn't quite work for me. the `::before` elements slides, alright, but there's also a circle left behind where it used to be in the unchecked state but half-hidden behind the checkbox background.

    • @reallygood7580
      @reallygood7580 4 ปีที่แล้ว

      im not sure that it will work, but try "z-index: 1;"

  • @akshaybedared
    @akshaybedared 5 ปีที่แล้ว +1

    Thank you :)

  • @carlosgaleanohn
    @carlosgaleanohn 7 ปีที่แล้ว +1

    Great job!!!

  • @gluebubbler
    @gluebubbler 4 ปีที่แล้ว +1

    i don't know how make circle in center. in Microsoft Edge not work (

  • @ДанькаКочкин
    @ДанькаКочкин 5 ปีที่แล้ว +2

    Thanks. By the way, I like classical music, but that was tooooooooooooooo schmaltzy.

  • @Seyfettin0
    @Seyfettin0 5 ปีที่แล้ว +2

    Hey please add the codes on descriptions .

  • @luiza4142
    @luiza4142 7 ปีที่แล้ว +1

    How to style a radio button??

  • @ck0024
    @ck0024 6 ปีที่แล้ว +1

    *Cool*

  • @mikebags6653
    @mikebags6653 6 ปีที่แล้ว +1

    it doesn't work in other browsers. it only works in chrome. can you help me?

  • @ChrisAdams-fc2mn
    @ChrisAdams-fc2mn 6 ปีที่แล้ว +1

    If I put this code in my CSS will it not affect every checkbox on my website?

  • @venturevpn
    @venturevpn 6 ปีที่แล้ว +1

    Send us , movie , you create app APK responsive scroll menu . Congratulations to you big developer congratulations to you

  • @michelventura3882
    @michelventura3882 5 ปีที่แล้ว +1

    thaaaaanks !

  • @s.agamerz7962
    @s.agamerz7962 3 ปีที่แล้ว +1

    Make a game using python or java

  • @taranagnew436
    @taranagnew436 5 ปีที่แล้ว +1

    i've tried everything and i just get a square check-box and not wat you have, plz help

    • @eccehomer8182
      @eccehomer8182 5 ปีที่แล้ว

      Make sure your code is absolutely the same - every character, every space. If it doesn't work then post your code here in a reply.

    • @taranagnew436
      @taranagnew436 5 ปีที่แล้ว

      HTML:

      Style Checkbox with CSS



      CSS:
      body{
      margin: 0;
      padding: 0;
      background: #f3f3f3;}
      .center{
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);}
      }
      input[type="checkbox"]
      {
      position: relative;
      width: 80px;
      height: 40px;
      -webkit-appearance: none;
      background: #c6c6c6;
      outline: none;
      border-radius: 20px;
      box-shadow: inset 0 0 5px rgba(255, 0, 0, 0.2);
      /*transition: .5s;*/
      }
      input:checked[type="checkbox"]
      {
      background: #03a9f4;
      }
      input[type="checkbox"]:before
      {
      content: '';
      position: absolute;
      width: 40px;
      height: 40px;
      border-radius: 20px;
      top: 0;
      left: 0;
      background: #0400ff;
      transform: scale(1.1);
      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
      transition: .5s;
      }
      input:checked[type="checkbox"]:before
      {
      left:40px;
      }

  • @douglaslisboa9
    @douglaslisboa9 6 ปีที่แล้ว +3

    Muito bom, parabéns \o/

  • @controlccontrolv4519
    @controlccontrolv4519 6 ปีที่แล้ว +1

    Hey I'II can to replay your code in my language on my channel?

  • @виртуоз_ру
    @виртуоз_ру 7 ปีที่แล้ว +2

    Красавчик

  • @deepakgurung309
    @deepakgurung309 6 ปีที่แล้ว +1

    input[type="checkbox'] is not working for firefox

    • @CyanLuk
      @CyanLuk 6 ปีที่แล้ว

      no me funciona
      lo copie tal cual lo vi en us video y no me hace las transiciones correctamente. no tube ningun error al copiarlo. que esta pasando?

  • @mdshabaz2591
    @mdshabaz2591 5 ปีที่แล้ว +2

    instead of music u can explain the code too

  • @link2web658
    @link2web658 5 ปีที่แล้ว +1

    dear sir
    Mujhe apni youtube play list ko apne php/html page per list karna or wo play kar per popup ho automatically update ho
    uvaaworld.com/gallery_backup.php ye website ka link hai kuch is traha se plz code ya video ka link send kijiye

  • @skentertainment337
    @skentertainment337 5 ปีที่แล้ว +1

    Bakwas video

  • @NadeemJohn-xu4lu
    @NadeemJohn-xu4lu ปีที่แล้ว +1

    NADEEMJOHN

  • @NadeemJohn-xu4lu
    @NadeemJohn-xu4lu ปีที่แล้ว

    NADEEMJOHN

  • @NadeemJohn-xu4lu
    @NadeemJohn-xu4lu ปีที่แล้ว

    NADEEMJOHN