How to create a switch button like Android with CSS?
Asked
Viewed 146 times
0
How can I create a switch button like the one on Android with CSS?
You need Javascript to do "on-off", or I can do this only with CSS?
I think it’s really duplicated, the JS that has in the answer there does not interfere with the functionality of on/off. That’s what you were looking for?
@Sergio the only problem is that I wanted to do something that could be used with Angularjs (I no longer use jQuery). I saw on the Internet that some did without Javascript, using a checkbox with the attribute for (with hidden visibility). It would be interesting to have an answer from this one, don’t you think?
But your question is "You need Javascript to do "on-off", or I can do this only with CSS?" if you get a good look at the answer there is no Javascript at all: https://jsfiddle.net/o525zr7b/
I think it’s really duplicated, the JS that has in the answer there does not interfere with the functionality of on/off. That’s what you were looking for?
– Sergio
@Sergio the only problem is that I wanted to do something that could be used with Angularjs (I no longer use jQuery). I saw on the Internet that some did without Javascript, using a checkbox with the attribute for (with hidden visibility). It would be interesting to have an answer from this one, don’t you think?
– Wallace Maxters
But your question is "You need Javascript to do "on-off", or I can do this only with CSS?" if you get a good look at the answer there is no Javascript at all: https://jsfiddle.net/o525zr7b/
– Sergio
You’ve wanted Angular for a while I made one in React :)
– Sergio
@Wallacemaxters a CSS-only example based on HTML attributes (properties), such as
checked
anddisabled
: https://answall.com/a/198805/3635– Guilherme Nascimento