我想在我的网页上添加一个表单,允许用户选择多个选项(不在下拉列表中)。例如,如果有3个可能的项目,则应将它们列出如下:
ITEM 1 ITEM 2 ITEM 3
它们应位于单独的“框”中,该框应是可选的。我不想在下拉列表或列表视图中执行此操作。我有什么选择?
我想我会使用checkbox
样式。您可以在Flask / WTF中执行此操作,但这是目标:
body {
background: white;
color: #323232;
margin: 0;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
font-family: Helvetica neue, roboto;
}
input[type=checkbox] {
display:none;
}
input[type=checkbox] + label {
background: #ccc;
font-style: italic;
padding: 20px;
cursor:pointer;
}
input[type=checkbox]:checked + label {
background: #f00;
font-style: normal;
}
<div style="inline-block">
<input type="checkbox" id="toggle" name="toggle" class="hideThis">
<label for="toggle">Toggle</label>
</div>
<div style="inline-block">
<input type="checkbox" id="toggle2" name="toggle2" class="hideThis">
<label for="toggle2">Toggle</label>
</div>
<div style="inline-block">
<input type="checkbox" id="toggle3" name="toggle3" class="hideThis">
<label for="toggle3">Toggle</label>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句