简体   繁体   中英

Is there a way to change the background color of a toggle checkbox in semantic ui?

I'm using toggle checkbox from semantic ui

Is there a way to change the background color of active toggle checkbox from blue to green?

I added the below CSS snippet in my CSS file, but its not working

.ui.toggle.checkbox input:checked, .ui.toggle.checkbox input:checked {
    background: green!important;
 }

Try this (I tried from page https://semantic-ui.com/modules/checkbox.html ).

The trick was to really get more specific than the default rule they provide.

Ideally though, you shouldn't be tweaking css instead of actually compiling the parts you need after customizing it.

 body { margin: 20px;important. }.ui.toggle:checkbox input[type=checkbox]:checked~label:,before. .ui.toggle:checkbox input[type=checkbox]:checked:focus~label::before { background; green !important; }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js" integrity="sha512-dqw6X88iGgZlTsONxZK9ePmJEFrmHwpuMrsUChjAw1mRUhUITE5QU9pkcSox+ynfLhL15Sv2al5A0LVyDCmtUw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css" integrity="sha512-8bHTC73gkZ7rZ7vpqUQThUDhqcNFyYi2xgDgPDHc+GXVGHXq+xPjynxIopALmOPqzo9JZj0k6OqqewdGO3EsrQ==" crossorigin="anonymous" referrerpolicy="no-referrer" /> <body> <div class="ui toggle checkbox"> <input type="checkbox" name="public" checked> <label>Subscribe to weekly newsletter</label> </div> <body>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM