0

get a minus "-" symbol inside checkbox using html and css only

I tried using

document.getElementsByTagName("input")[0].indeterminate = true;

but requirement is using html and css only

Priya
  • 1,359
  • 6
  • 21
  • 41
Rohith Sai
  • 41
  • 1
  • 2
  • 1
    please add your code here :) – Shadow Jun 30 '16 at 08:42
  • 1
    You can use the after pseudo class and absolute position it. See http://stackoverflow.com/questions/4148499/how-to-style-checkbox-using-css, that seem to have many solutions to your question. – Arathi Sreekumar Jun 30 '16 at 08:43
  • 1
    do you mean "-" for the replacement of check mark? please show your code as well – Lucian Jun 30 '16 at 08:55
  • 1
    use can use input indeterminate https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_checkbox_indeterminate – Sooraj s May 06 '22 at 13:26

1 Answers1

2

It sounds like you want a label posing like a checkbox, with a minus symbol inside. Like this:

input {
  display: none
}

label {
  padding: 0 6px;
  border: 1px solid #eee
}

input:checked+label {
  background: #000;
  color: #fff
}
<div>
  <input type="checkbox" id="box">
  <label for="box">-</label>
</div>
kelsny
  • 23,009
  • 3
  • 19
  • 48
Handsken
  • 664
  • 11
  • 26