我正在尝试个性化Checkbox的外观,但这仅适用于谷歌浏览器,因为mozilla不起作用我不知道如何解决这个问题,这是我的代码:
示例:
¡请!在您发布任何回复之前,请参阅2个浏览器中的示例 这种情况是Chrome和Mozilla。
来自Google Chrome和Mozilla的图片
Chrome:
的Mozilla
CSS:
#div-tallas .seleccion-talla .btn-default{
padding: 6px 7px;
font-weight: 600;
font-size: 1.2em;
letter-spacing: 0px;
min-width: 40px;
margin-left: 1px !important;
}
#div-tallas input[type="checkbox"] {
/* 1 */
display: inline-block;
height: 36px;
width: 36px;
border: 2px solid #000;
-moz-border: 2px solid #000;
/* 2 */
overflow: hidden;
/* 3 */
margin-top: -4px;
vertical-align: middle;
/* 4 */
-webkit-appearance: none;
-moz-appearance: none;
outline: 0;
/* 5 */
background: #e5e4e4;
-moz-background: #e5e4e4;
}
/*
* Checked
*/
#div-tallas input[type=checkbox]:checked {
/* 1 */
display: inline-block;
height: 36px;
width: 36px;
border: 2px solid #e5e4e4 !important;
-moz-border: 2px solid #e5e4e4 !important;
/* 2 */
overflow: hidden;
/* 3 */
margin-top: -4px;
vertical-align: middle;
/* 4 */
-webkit-appearance: none;
-moz-appearance: none;
outline: 0;
/* 5 */
background: #ff6500 !important;
background-color: #ff6500 !important;
padding: 2px;
transition: background 0.4s linear 0s, color 0.4s linear 0s;
}
/* Checkbox */
#div-tallas input[type=checkbox]:checked:before,
#div-tallas input[type=checkbox]:indeterminate:before {
content: "\f00c";
font-family: FontAwesome;
font-size: 32px;
-webkit-font-smoothing: antialiased;
text-align: center;
line-height: 26px;
color: #e5e4e4;
z-index: 888;
margin-left: -1px;
}
#div-tallas input[type=checkbox]:indeterminate:before {
content: "\f068";
}
答案 0 :(得分:1)
标签样式怎么样?
#div-tallas {
background-color: #e5e4e4 !important;
min-height: 40vh;
}
#div-tallas input[type="checkbox"] {
display: none;
}
#div-tallas input[type="checkbox"] + label {
padding-left: 0;
}
#div-tallas input[type="checkbox"] + label:before {
/* 1 */
font: 32px/32px 'FontAwesome';
text-align: center;
display: inline-block;
height: 36px;
width: 36px;
border: 2px solid #000;
overflow: hidden;
margin-top: -4px;
vertical-align: middle;
background: transparent;
/* to show content */
content: "\00a0";
margin-right: 8px;
}
/*
* Checked
*/
#div-tallas input[type=checkbox]:checked + label:before {
border: 2px solid transparent;
background: #ff6500;
transition: background 0.4s linear 0s, color 0.4s linear 0s;
}
/* Checkbox */
#div-tallas input[type=checkbox]:checked + label:before,
#div-tallas input[type=checkbox]:indeterminate + label:before {
content: "\f00c";
color: #e5e4e4;
}
#div-tallas input[type=checkbox]:indeterminate + label:before {
content: "\f068";
}
答案 1 :(得分:0)
这不是100%完美,但它确实向您展示了一个纯Chrome复选框的工作示例,该复选框适用于Chrome和Firefox。
<强> HTML 强>
<div id="div-tallas">
<div class="quiero-este">
<h5>¡Quiero este!</h5>
<div class="checkbox check-primary m-top-40 text-center">
<input type="checkbox" value="1" id="checkbox1" />
<label for="checkbox1"></label>
</div>
</div>
</div>
<强> CSS 强>
#div-tallas {
background-color: #e5e4e4 !important;
min-height: 40vh;
}
#div-tallas input[type=checkbox] {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background: transparent;
visibility: hidden;
}
#div-tallas input[type=checkbox],
#div-tallas input[type=checkbox] + label::before {
cursor: pointer;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
#div-tallas input[type=checkbox] + label::before {
content: '';
text-align: center;
background: #e5e4e4;
display: inline-block;
pointer-events: none;
opacity: 1;
color: black;
border: 3px solid black;
width: 36px;
height: 36px;
}
#div-tallas input[type=checkbox] + label {
line-height: 20px;
margin: 0 15px 0 15px;
}
#div-tallas input[type=checkbox]:hover {
cursor: pointer;
}
#div-tallas input[type=checkbox]:hover + label::before {
content: '';
background: #e5e4e4;
}
#div-tallas input[type=checkbox]:checked + label::before {
background: #ff6500 !important;
background-color: #ff6500 !important;
outline: 0;
content: "\f00c";
font-family: FontAwesome;
font-size: 32px;
-webkit-font-smoothing: antialiased;
text-align: center;
line-height: 26px;
color: #e5e4e4;
z-index: 888;
margin-left: -1px;
}
#div-tallas input[type=checkbox]:checked:hover + label::before {
opacity: 1;
}
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
}
希望这有帮助。