【问题标题】:Multiple Checkboxes in different colors several id不同颜色的多个复选框几个id
【发布时间】:2020-12-19 03:20:48
【问题描述】:

我想知道如何为复选框着色,我必须在不使用php的情况下创建几种不同的颜色,我们如何处理不同id的复选框?内容:'✔'不显示..感谢您的帮助

input[type='checkbox'] {
  color:orange;
  outline: 1px solid orange;
  width: 14px !important;
  height: 14px !important;
  margin: 5px;
  -webkit-appearance: none;
  -moz-appearance: none;
  -o-appearance: none;
  content: '';
  box-shadow: none;
  font-size: 0.8em;
  text-align: center;
  line-height: 1em;

}

input[type="checkbox"]:not(:checked) + label:after,
input[type="checkbox"]:checked + label:after {
     content: '✔';

     color: orange;
}
<input type="checkbox" id="orange" value="" checked="checked">
<input type="checkbox" id="purple" value="">
<input type="checkbox" id="pink"  value="">

com/h533A.jpg

【问题讨论】:

标签: css checkbox styles


【解决方案1】:

input[type='checkbox']{
  width: 14px ;
  height: 14px ;
  outline: 1px solid orange;
  box-shadow: none;
  font-size: 1em;
  text-align: center;
  line-height: 1em;
  background: white;
  -webkit-appearance: none;
 -moz-appearance: none;
 -o-appearance: none;
 appearance: none;
}
input[type='checkbox']:checked:after {
  content: '✔';
  color: orange;
}
&lt;input type="checkbox" class="checkbox" id="orange" value="" checked="checked"&gt;

您可以使用此代码与您的代码进行比较和检查

CSS 代码

input[type='checkbox']{
  width: 14px ;
  height: 14px ;
  outline: 1px solid orange;
  box-shadow: none;
  font-size: 1em;
  text-align: center;
  line-height: 1em;
  background: white;
  -webkit-appearance: none;
 -moz-appearance: none;
 -o-appearance: none;
 appearance: none;
}
input[type='checkbox']:checked:after {
  content: '✔';
  color: orange;
}

html代码

<input type="checkbox" class="checkbox" id="orange" value="" checked="checked">

【讨论】:

  • 谢谢P_Daiki,但我已经尝试过你的代码,✔不是橙色而是绿色..
【解决方案2】:

我将 '✔' 替换为 '\2713';在 css 中,它可以工作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-20
    • 1970-01-01
    • 2017-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多