我为我的应用程序使用了自定义复选框样式,我目前面临的问题是呈现了自定义复选框样式和普通的自举复选框。
您可以猜测自定义复选框不是可单击的,而是显示的。
以下是html的示例:
<div class="form-group">
<strong class="container_check version_2">Ebay Angebot?
<%= check_box_tag :ebay_offer, true, [] %>
<span class="checkmark"></span>
</strong>
</div>
这是控制台抛出的内容:
<input type="checkbox" name="ebay_offer" id="ebay_offer" value="true" checked="checked">
相应的引导程序类(不是我的自定义对勾标记):
input[type=checkbox], input[type=radio]
我的自定义对勾标记类
/** CHECKMARKS */
.container_check {
display: block;
position: relative;
font-size: 14px;
font-size: 0.875rem;
padding-left: 30px;
line-height: 1.3;
margin-bottom: 10px;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none
}
.container_check input {
position: absolute;
opacity: 0;
cursor: pointer
}
.container_check input:checked~.checkmark {
background-color: #2FE7B1;
border: 1px solid transparent
}
.container_check .checkmark {
position: absolute;
top: 0;
left: 0;
height: 20px;
width: 20px;
border: 1px solid #d2d8dd;
background-color: #fff;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-ms-border-radius: 3px;
border-radius: 3px;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out
}
.container_check .checkmark:after {
content: "";
position: absolute;
display: none;
left: 7px;
top: 3px;
width: 5px;
height: 10px;
border: solid white;
border-width: 0 2px 2px 0;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg)
}
.container_check.version_2 {
padding: 6px 0 0 45px;
min-height: 30px
}
.container_check.version_2 .checkmark {
height: 30px;
width: 30px
}
.container_check.version_2 .checkmark:after {
left: 12px;
top: 8px;
width: 5px;
height: 10px
}
.container_check input:checked~.checkmark:after {
display: block
}
答案 0 :(得分:2)
通常,跨度需要在字段内或标签内。您可以尝试以下格式:
<%= check_box_tag :ebay_offer, true, [] do %>
<span class="checkmark"></span>
<% end %>
或
<%= label_tag :ebay_offer do %>
<%= check_box_tag :ebay_offer %>
Any desired label text <span class="checkmark"></span>
<% end %>