Adjusting the color scheme of a Checkbox Button in Bootstrap 4

Seeking advice on locating overrides for certain css properties. Take a look at this illustration on https://getbootstrap.com/docs/4.1/components/buttons/#checkbox-and-radio-buttons. The contrast in color between the activated and deactivated states is not distinct enough for my preferences. I am interested in selecting custom colors for each state.

Answer №1

Here is a solution for overriding the default bootstrap styles, although I recommend using your own custom class instead.

    .btn-secondary:not(:disabled):not(.disabled).active, .btn-secondary:not(:disabled):not(.disabled):active, .show>.btn-secondary.dropdown-toggle{
    color: #fff;
    background-color: green;
    border-color: green;
}

.btn:not(:disabled):not(.disabled) {
    cursor: pointer;
    background: red;
    border-color: red;
}

Consider something like this:

.btn .btn-secondary .focus .toggle-on-off {
        background: red;
        border-color: red;
}

.btn .btn-secondary .focus .active toggle-on-off{
        background-color: green;
        border-color: green;
}

Bootstrap adds the class active, which is why it's important to customize your own classes.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to stack one Canvas on top of another?

Right now, I am engaged in a process that involves: creating a canvas and attaching it to a division applying a background image through CSS to that canvas. drawing a hex grid on the canvas placing PNGs on the canvas. animating those PNGs to show "movem ...

A guide on layering .ogg video with .png image using HTML5 and CSS3

I am having difficulty achieving the desired effect, even when using z-index and position:absolute. My goal is to overlay a .png image on top of a video, while still allowing the transparent parts of the .png file to reveal the video playing in the backg ...

Arrange and display similar objects together

I have a list of items in a listView that need to be visually grouped based on their class, displayed within boxes. For example, I have 5 items with the following classes: <div class="1"></div> <div class="1"></div> <div class= ...

Is there a way to change my cursor to a pointer finger when hovering over my box?

<script type="text/javascript"> function draw() { var canvas = document.getElementById('Background'); if (canvas.getContext) { var ctx = canvas.getContext('2d'); ctx.lineWidth = 0.4 ctx.strokeRect(15, 135, 240, 40) Is there a w ...

Creating a sidebar that extends to the bottom of the webpage using

My friend is currently designing his website, and he has encountered an issue with the sidebar. He wishes for the sidebar to extend all the way down to the bottom of the page rather than just the visible portion within the browser window. You can view the ...

What is the secret to keeping links opaque even after they have been hovered over and their target is visible?

There are four links on my page that toggle the visibility of different divs. You can see them in action here. The code for the links is shown below: <li class="togglelink fadein button" data-block="albums" id="togglealbums">Albums</li> <l ...

Changing the Div heights in Material UI with grid layout customization

I have a project that requires me to implement material-ui. Is there a way I can adjust the width and height of the div containing the "Sign In With" text (as shown in the first image) to bring the buttons closer to the text? Transformation from this: ht ...

Is it possible to set a click event or <A> link on an entire Ember component?

One of my Ember components has a tagName:'li' This is how the template appears: <div> title</div> <div> image </div> <div> text </div> The result is <li> blocks consisting of the elements above, displ ...

Ensuring a fixed table with vertical scrolling only, no horizontal scrolling, while scrolling in either direction

I'm working with an HTML fixed design that contains a center-aligned table with extensive data scrollable both vertically and horizontally. To address the issue of keeping column headers visible when scrolling vertically, I used jQuery's clone() ...

Utilizing jQuery for automatic redirection in place of performing regular AJAX requests

My form validation script using bootstrapvalidator () performs an ajax call upon successful validation (e.g., checkbox checked, not empty). However, I encountered a problem when trying to integrate it with the ICheck plugin (). Instead of executing the aj ...

"Exploring the concept of responsive design: understanding the distinction between media query width and actual

Apologies for the lengthy description, but I want to provide as much detail as possible. I recently encountered an issue (which I managed to resolve, but the root cause eluded me). The crux of the problem was that when resizing the browser, specificall ...

Chrome is the only browser that displays the correct number of columns, unlike IE and Firefox

[Link removed] Is anyone else experiencing an issue with the columns on a website layout? I have 5 columns set up with each post taking up 20% width. It looks fine in Chrome, but in IE and Firefox, the last column gets pushed below so there are only 4 col ...

A guide on detecting overflow in a React functional component

I am in search of a way to determine if a div contains overflowing text and display a "show more" link if it does. While researching, I came across an insightful Stack Overflow answer on checking for overflow in a div. The answer suggests implementing a fu ...

What steps should I follow to ensure that the "-> comes after the text?

Here is the link to my page: . Currently, the arrow appears under the text. I am looking for a way to rearrange it so that the arrow comes after the text while still maintaining its hover effect. Can you provide any suggestions? ...

Display the table once the radio button has been selected

Before we proceed, please take a look at the following two images: image 1 image 2 I have over 20 fields similar to 'Image 1'. If "Yes" is selected, then a table like in 'Image 2' should be displayed. This means I have 20 Yes/No fields ...

Bootstrap enables a 4 column layout that automatically adjusts to different

I am looking to create a row with 4 columns that will adjust based on the user's device. When viewed on a tablet, the row should display 2 columns side by side and the other 2 columns below them. On mobile devices, I want the row to show as 1 column w ...

Mastering the art of manipulating Div elements using CSS for the optimal Print View experience

I have a table with several columns and 1000 rows. When I print the page, it breaks the rows onto different pages, showing the remaining rows on subsequent pages. I want to display the complete record in one go. Below is a sample code with only one row in ...

What is the process for immediately changing the background color of an input field as soon as text is entered?

I am encountering an issue with the code snippet provided below. My goal is to change the background color of an input field as soon as I start typing something into it. The scenario involves 4 input fields where if the submit button is clicked and any f ...

Swap File Field for Picture Graphic - HTML/CSS

I am looking to enhance the appearance of my form by replacing the generic File Field with a more aesthetically pleasing Image Icon. If you click on this Camera Icon, it will open up a Browse window: For a demonstration, check out this JsFiddle link: htt ...

Floating elements are misaligned and not laying out correctly

I've encountered an issue where the footer div is appearing behind the right-hand side div. I have a central container div with two floated divs next to each other, and the footer is separate. I've spent hours trying to fix it but can't figu ...