Coder Social home page Coder Social logo

Comments (9)

ghinda avatar ghinda commented on May 26, 2024

Sure. You can take a look at the ios and android themes on the main demo page, to see how it works for the light/checkbox switch:

https://ghinda.net/css-toggle-switch/

For the switch/radio switch you could use the nth-child selector to target an individual label, and create a pseudo-element for it that fills up the entire background. This way you could have a different background for each selected item.

from css-toggle-switch.

lcsqlpete avatar lcsqlpete commented on May 26, 2024

I'd like to do that too but my css skills aren't up to it. Any chance you could publish an example?

from css-toggle-switch.

ghinda avatar ghinda commented on May 26, 2024

Sure, here's a demo:
http://s.siloz.io/G

from css-toggle-switch.

lcsqlpete avatar lcsqlpete commented on May 26, 2024

from css-toggle-switch.

ghinda avatar ghinda commented on May 26, 2024

If you use Sass and Bootstrap 4, you can get the colors from their variables file:
https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss#L46

from css-toggle-switch.

lcsqlpete avatar lcsqlpete commented on May 26, 2024

from css-toggle-switch.

lcsqlpete avatar lcsqlpete commented on May 26, 2024

on't seem to be able to get this working. I'm using it on a switch-light not a swith-toggle, not sure if that makes any difference. Here's the html.

<label class="switch-light" onclick=""> <input name="Publish" type="checkbox" {{Published}}> <span class="alert alert-light"> <span>No</span> <span>Yes</span> <a class="btn btn-success disabled"></a> </span> </label>

and the css:

`input:checked:nth-of-type(1) ~ a {
background: red;
}

input:checked:nth-of-type(2) ~ a {
background: green;
}`

Both parts of the switch appear in the btn-success color. I also tried it without the class statement in the a tag and no colors were displayed.

from css-toggle-switch.

ghinda avatar ghinda commented on May 26, 2024

That will only work for the radio switch.
Try this for the checkbox switch: http://s.siloz.io/H

from css-toggle-switch.

lcsqlpete avatar lcsqlpete commented on May 26, 2024

from css-toggle-switch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.