How to create an HTML/CSS only toggle switch.

Поділитися
Вставка
  • Опубліковано 27 сер 2024
  • In this video I'll be showing you how you can replace a normal checkbox with an iOS style toggle switch.
    Sourcecode: codepen.io/Lewi... If you enjoy my videos and would like to buy me a beer you can donate here: paypal.me/iamlewislong

КОМЕНТАРІ • 38

  • @TonyEnglandUK
    @TonyEnglandUK 3 роки тому

    Just viewed it on Codepen, very nice work.

  • @Cognitoman
    @Cognitoman 7 років тому

    thanks dude. I tired to this myself but my blur and box shadow was off thanks for the help

  • @dhirendersingh6227
    @dhirendersingh6227 8 років тому +1

    thanks
    and keep on making some cool stuff with css so that i can learn.

    • @LewisLong
      @LewisLong  8 років тому

      Thanks for watching, Dhirender. I have some more planned for the next few weeks. Hope you find them helpful.

  • @anaaremere2mere
    @anaaremere2mere 7 років тому +2

    nice video where you can learn a lot of commands. Thanks for sharing this with us.
    Unfortunately for me it is not working. I have copied your code in my coding software but most probably I have forgot to add something. Have to mention that I am really new in this king of things and I am in learning process.

    • @LewisLong
      @LewisLong  7 років тому +2

      Keep at it Istrate, you'll get it. It's like anything else practice makes perfect.

  • @OnlineTutorialsYT
    @OnlineTutorialsYT 7 років тому +1

    awesome bro

  • @munapadhi8723
    @munapadhi8723 6 років тому

    nice video its very help full . thanks for your good job:)

  • @abdullahkhallaf73
    @abdullahkhallaf73 3 роки тому

    That's great man thank u❤️

  • @Andrei_Calazans
    @Andrei_Calazans 7 років тому

    Thanks mate really enjoyed it

  • @sherifahmed1569
    @sherifahmed1569 4 роки тому

    How to add more than 2

  • @Malik-gz2eu
    @Malik-gz2eu 2 роки тому

    How do you make it do soemthing?

  • @crispingarciagompad7395
    @crispingarciagompad7395 8 років тому

    i really love this video

  • @OnlineTutorialsYT
    @OnlineTutorialsYT 7 років тому +1

    you are great

  • @supercellclashroyale4134
    @supercellclashroyale4134 6 років тому

    Are you create interactive assistant ? Start with this button?

  • @taranagnew436
    @taranagnew436 4 роки тому

    how do you get the testing window in visual studio code?

  • @rafaeltosi
    @rafaeltosi 6 років тому

    Sorry for the late comment, but is there an easy way ti resize the button? Thanks

    • @LewisLong
      @LewisLong  6 років тому

      You can either add a "transform: .scale(x,y)" property to .switch > div or create a class like .double-size {transform: scale(2.0) and add it to the buttons you want to resize

  • @SimPwear84
    @SimPwear84 7 років тому

    Nice!

  • @jamming1984
    @jamming1984 6 років тому

    gracias genio!!! :)

  • @martinmtandi335
    @martinmtandi335 7 років тому

    how can i insert text inside the switch e.g so a user can tell its on or off

    • @LewisLong
      @LewisLong  7 років тому

      You could add an :after pseudo element to the input[type=checkbox]:checked + .switch-btn element and set your text as the content property. Then position and style it the way you want.

  • @smiljkachu
    @smiljkachu 8 років тому

    great tut! but i have an issue. when i get to opacity, it just stop working. its dead. i cant flip it its just like an empty unclickable div. :S

    • @LewisLong
      @LewisLong  8 років тому +2

      Oh bummer, that's no good. Try changing your CSS from .switch { opacity: 0; } to .switch > input[type=checkbox] { opacity: 0; } and see if that helps. Also, double check that your checkbox is inside your label. I have a codepen setup for reference. codepen.io/LewisLong/pen/BKEMjP

  •  3 роки тому

    good job but de example or source code its not same as the video !! its very ugly

  • @r4mp4gehd71
    @r4mp4gehd71 7 років тому

    SuperVideo now my question is how can I now with a switch 2 php datein run for example the switch is left so out then he should execute a from: php and if he is right is an an.php

    • @LewisLong
      @LewisLong  7 років тому

      If you are looking to trigger some server side functionality you can either use JavaScript to make an AJAX request directly tied to the switch or if your switch is inside a form you can add the state of the switch to the body of the POST request on that form.

    • @r4mp4gehd71
      @r4mp4gehd71 7 років тому

      I am a complete beginner you can write times an example here how this could look would be really dear because I have searched the whole network not really something

    • @r4mp4gehd71
      @r4mp4gehd71 7 років тому

      so it looks so in the main file and there would be the function with pure

    • @r4mp4gehd71
      @r4mp4gehd71 7 років тому

      can you give me an example how it could look because I am complete beginner

  •  7 років тому

    Nice vid, will you share the code?

    • @LewisLong
      @LewisLong  7 років тому

      Thanks. I just added a link in the description.

    •  7 років тому

      Thanks :)

  • @raiyajessa1
    @raiyajessa1 7 років тому

    Thanks for the video! I was able to implement the toggle switch in my project here: codepen.io/raiyaj/full/KaPdGV/

    • @LewisLong
      @LewisLong  7 років тому

      Awesome! The app is really clean looking. Thanks so much for sharing Raiya!

  • @jonashatlen5606
    @jonashatlen5606 6 років тому

    I only got 2 boxes :P