3

Here is the new checkbox from bootstrap4 : Bootstrap4 checkbox:

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

The default <input> checkbox is hidden by default, it is visible only on click. Is there a way to make it always visible.

Fiddle : jsFiddle

Edit : This is how I want it to be by default.

enter image description here

8
  • Can you elaborate on the default checkbox is always hidden? Jan 5, 2016 at 13:22
  • I meant to say it is hidden by default. You can check the jsFiddle that I have added.
    – Zeeshan
    Jan 5, 2016 at 13:24
  • Perhaps change body background color to see it clearly. Jan 5, 2016 at 13:25
  • do you want the checkbox checked by default? -
    – Denis Tsoi
    Jan 5, 2016 at 13:25
  • I want the checkbox unchecked by default with the blue border that come when you uncheck it manually.
    – Zeeshan
    Jan 5, 2016 at 13:27

1 Answer 1

5

That's the style applied to the .c-indicator element when the checkbox itself is focused:

.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 to have that apply at all times, simply reuse that style declaration in your own CSS, dropping the .c-input>input:focus~ completely:

.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;
}

Modified JSFiddle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.