Ensure that the checkbox remains constant and visible at all times when using Bootstrap

Introducing the latest checkbox design in Bootstrap4 : Check out the Bootstrap4 checkbox:

<label class="c-input c-checkbox">
    <input type="checkbox">
    <span class="c-indicator"></span>
    Click here
 </label>

The standard <input> checkbox is initially hidden, and only appears when clicked. Is there a way to keep it visible at all times?

Try it out on Fiddle : jsFiddle

Edit : This is how I envision it looking by default.

https://i.sstatic.net/iCIV8.png

Answer №1

When the checkbox is focused, the style applied to the .c-indicator element changes:

.c-input>input:focus~.c-indicator {
  -webkit-box-shadow: 0 0 0 .075rem #fff,0 0 0 .2rem #0074d9;
  box-shadow: 0 0 0 .075rem #fff,0 0 0 .2rem #0074d9;
}

If you want this style to apply at all times, simply reuse the same style declaration in your own CSS without the need for .c-input>input:focus~:

.c-indicator {
  -webkit-box-shadow: 0 0 0 .075rem #fff,0 0 0 .2rem #0074d9;
  box-shadow: 0 0 0 .075rem #fff,0 0 0 .2rem #0074d9;
}

View Modified JSFiddle.

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

Steps to display a div on top of a background image

Here is a visual representation of my design for better understanding: I am currently working on developing the central content that overlays the image. However, when I insert divs with background colors into my HTML to test their placement, I do not see ...

Is there a way to change the CSS of a sibling element when hovering over it

Imagine a scenario where hovering over one row changes its color. However, what if we want all rows of the same color to highlight when any row is hovered over? Is it possible to achieve this using just CSS? .red-row:hover { background-color: red; } ...

What is the best way to create a hover delay in jQuery?

I am trying to make a slider with thumbnails underneath the slides. I would like to hover over a thumbnail image and have the slide change to match the thumbnail after a one-second delay. Is there a way to achieve this? $(function(){ $("#main ...

Enhancing productivity with a more streamlined process for creating a responsive website design through the optimization of

I recently had the task of placing two images in a band on a webpage and ensuring they were responsive to different screen sizes. Image 'a' represented a circular logo, while image 'b' was a rectangular logo. The red band served as the ...

Enhancing WordPress Accessibility with Google Tag Manager

I have been utilizing the Google Tag Manager for WordPress plugin on my WordPress website. I have come across some important issues concerning compliance with the WCAG 2.0 accessibility guidelines. It has been brought to my attention that the Google Tag ...

I'm looking to design a search/filter feature for a website that is specific to my local area, complete with a

I have created a local page search input box that currently filters results as you type. However, I am looking to modify it so that the search/filter function only executes when a specific button is pressed. Essentially, I want users to input their lookup ...

utilizing a Bootstrap modal element throughout multiple HTML documents

I have a bootstrap modal dialog div that I want to use in all 4 html pages of my web application without repeating the code. I have a common JavaScript file for this purpose. What is the best way to achieve this? <!-- Modal --> <div class="modal ...

Internet Explorer 10 offers 3D transformation capabilities

My 3D rotating image carousel works well in Chrome and Firefox but not in IE. I am aware that IE10+ does not fully support the preserve-3d tag, and although there are workarounds by applying transforms to the children instead, I have been unsuccessful in ...

Synchronize two div elements with JavaScript

The demonstration features two parent divs, each containing a child div! The first parent div's child div is draggable and resizable using JQueryUI. There are events for both dragEnd and resizeEnd associated with this div. The goal is to synchronize ...

Produce an additional page while remaining on the present one

I have a PHP-based invoice system that displays all customer invoices. I am interested in adding a feature that allows users to print an invoice directly from the list page without navigating away. While I am familiar with window.print() and media="print" ...

What could be the reason for the react-bootstrap text-center not functioning properly? And why is my HR element automatically centering itself when I adjust the width?

Hello everyone, I am currently working on creating the front-end of my website using react-bootstrap. I am facing an issue where when I try to change the width of my hr element, it automatically centers itself. I also attempted to use the className "text-c ...

Changing Background Images Based on Screen Size in CSS Media Queries

Hey there, I am currently using two different header images - one for desktop and another for both tablet and mobile devices. I am wondering how I can automatically switch from the desktop header image to the mobile/tablet header image when the screen siz ...

Is it advisable to utilize CSS3 media queries to serve varied image sizes for retina display devices?

Although many questions similar to mine have been asked before, I believe my situation is slightly different. I have recently created a mobile app using JQM + Cordova/PhoneGap. In the beginning, I utilized large images aimed at retina display devices and ...

Is the footer consistently at the bottom of the page, expanding the container alongside it?

Looking to ensure that my footer remains at the bottom of the site, with the container expanding when there isn't enough content to fill the browsing window. Additionally, as new data is added to the menu or information block, the container should str ...

Attempting to arrange form input fields into groups of three columns

I am facing a challenge in arranging my input fields within the form in a column of 3. The issue is that I have more code than anticipated, making it difficult to achieve this layout. Despite several attempts, nothing seems to be working. I have spent hour ...

Arranging nested Divs for horizontal scrolling purposes

I'm struggling to achieve horizontal scrolling only in my provided example link HERE. It seems like a simple fix should be adding {overflow-x:auto; and overflow-y:hidden;} in the CSS, but I've tried that and it's not giving me the desired re ...

The best practices for coding Jquery plugins to adhere to style guidelines

I have been grappling with this issue for quite some time now, and I am seeking feedback from others. I am in the process of creating a personalized library to expedite web app development, and I want to ensure that I adopt the correct approach. My intenti ...

What is the method to prevent scrolling on the body while allowing scrolling on a specific div element?

<html> <body> <div class="container"> <div class="menu"></div> <div class="list"></div> </div> </body> </html> .menu{ float:left; width:50%; } .list{ float:right; width:50% ...

The appearance of Bootstrap React Nextjs doesn't quite match what's shown in the documentation

I am developing the frontend of my application using a combination of bootstrap, react, and nextjs. I attempted to implement the example provided by react-bootstrap at https://codesandbox.io/s/github/react-bootstrap/code-sandbox-examples/tree/master/basic. ...

Identify and emphasize CSS codes within PHP files using Notepad++

I'm working with a PHP file in Notepad++ that correctly highlights PHP code. Within this file, I have JavaScript code which is properly recognized between the <script type="text/javascript"> and </script> tags. However, the CSS code withi ...