gpt4 book ai didi

html - 无法单击复选框 - 自定义 Css

转载 作者:搜寻专家 更新时间:2023-10-31 22:54:42 24 4
gpt4 key购买 nike

我有一个复选框,虽然单击它时什么也不做,但除非发生某些更改,否则 css 似乎是正确的。它附加了一个类。

这在我删除 css 时有效,尽管我认为“之后”某处有错误

  • 请参阅 JSFiddle *

https://jsfiddle.net/bLg5juxd/

.form-flat-radio,
.form-flat-checkbox {
margin: 0;
cursor: pointer;
display: block;
position: relative;
padding: 0 0 0 30px;
}

.dh-ie .form-flat-radio,
.dh-ie .form-flat-checkbox {
padding: 0;
}

.form-flat-radio input,
.form-flat-checkbox input {
left: -9999px;
position: absolute;
}

.dh-ie .form-flat-radio input,
.dh-ie .form-flat-checkbox input {
position: relative;
left: auto;
}

.form-flat-radio i,
.form-flat-checkbox i {
background: none repeat scroll 0 0 #fff;
border-style: solid;
border-width: 1px;
display: block;
height: 17px;
left: 0;
outline: medium none;
position: absolute;
top: 5px;
border-color: #d5d5d5;
width: 17px;
top: 50%;
margin-top: -8.5px;
color: #1e1e1e;
}

.dh-ie .form-flat-radio i,
.dh-ie .form-flat-checkbox i {
display: none;
}

.form-flat-radio i:after,
.form-flat-checkbox i:after {
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: opacity 0.1s ease 0s;
-o-transition: opacity 0.1s ease 0s;
transition: opacity 0.1s ease 0s;
}
<div class="form-flat-checkbox pull-left">
<input type="checkbox" name="rememberme" id="rememberme" value="forever"><i></i>&nbsp;Remember Me
</div>

最佳答案

您需要将自定义输入和文本包装在带有 for 属性集的标签中。

<div class="form-flat-checkbox pull-left">
<input type="checkbox" name="rememberme" id="rememberme" value="forever">
<label for="rememberme">
<i></i>&nbsp;Remember Me
</label>
</div>

在这种情况下,您还可以将按钮的样式更改为display: none;。我个人更喜欢这种方法,而不是将其移出页面。此外,这还提供了按下文本以触发复选框的好处。

.form-flat-radio input,
.form-flat-checkbox input {
display: none;
}

参见:https://jsfiddle.net/bLg5juxd/4/

.form-flat-radio,
.form-flat-checkbox {
margin: 0;
cursor: pointer;
display: block;
position: relative;
padding: 0 0 0 30px;
}
.dh-ie .form-flat-radio,
.dh-ie .form-flat-checkbox {
padding: 0;
}
.form-flat-radio input,
.form-flat-checkbox input {
display: none;
}
.dh-ie .form-flat-radio input,
.dh-ie .form-flat-checkbox input {
position: relative;
left: auto;
}
.form-flat-radio i,
.form-flat-checkbox i {
background: none repeat scroll 0 0 #fff;
border-style: solid;
border-width: 1px;
display: block;
height: 17px;
left: 0;
outline: medium none;
position: absolute;
top: 5px;
border-color: #d5d5d5;
width: 17px;
top: 50%;
margin-top: -8.5px;
color: #1e1e1e;
}
.dh-ie .form-flat-radio i,
.dh-ie .form-flat-checkbox i {
display: none;
}
.form-flat-radio i:after,
.form-flat-checkbox i:after {
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: opacity 0.1s ease 0s;
-o-transition: opacity 0.1s ease 0s;
transition: opacity 0.1s ease 0s;
}
.form-flat-radio input:checked + i:after,
.form-flat-checkbox input:checked + i:after {
opacity: 1;
background-color: red;
}
.form-flat-radio i {
-webkit-border-radius: 50%;
border-radius: 50%;
}
.form-flat-radio i:after {
-webkit-border-radius: 50%;
border-radius: 50%;
content: "";
height: 7px;
left: 4px;
top: 4px;
line-height: 1;
width: 7px;
position: absolute;
background: #1e1e1e;
}
.form-flat-checkbox i:after {
content: "\f00c";
position: relative;
display: inline-block;
font-family: "FontAwesome";
font-style: normal;
font-weight: normal;
line-height: 1;
text-decoration: inherit;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
speak: none;
}
.form-flat-checkbox i:after {
font-size: 12px;
height: 17px;
left: -1px;
text-align: center;
position: absolute;
top: 50%;
-webkit-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
-o-transform: translate(0, -50%);
transform: translate(0, -50%);
margin-top: 2px;
width: 17px;
opacity: 0;
filter: alpha(opacity=0);
line-height: 1;
}
<div class="form-flat-checkbox pull-left">
<input type="checkbox" name="rememberme" id="rememberme" value="forever">
<label for="rememberme">
<i></i>&nbsp;Remember Me
</label>
</div>

关于html - 无法单击复选框 - 自定义 Css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47747170/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com