我一直试图让它工作一段时间,我似乎无法让它工作。请有人帮忙。 “切换”按钮不与输入框内联。一旦我需要它们,所以当有很多东西时,它会正确地形成网格,因为一切都是动态发生的。
我已经尝试过Div而不是标签我已经尝试过标签和输入组合,但要么我没有得到所需的结果,要么它根本不起作用
以下是代码:
.uni_controls {
margin: 5px;
background-color: orange;
}
.uni_controls input {
width: 150px;
height: 35px;
box-sizing: border-box;
border-radius: 10px;
border: 1px solid #00c1ff;
color: #00c1ff;
font-size: 10px;
outline: none;
text-align: center;
background-color: white;
margin: 2.5px;
}
.uni_controls label {
position: relative;
display: inline-block;
width: 150px;
height: 35px;
outline: none;
border-radius: 10px;
border: 1px solid #00c1ff;
margin: 2.5px;
}
.uni_controls label input {
display: none;
}
.uni_controls label slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: white;
transition: .4s;
border-radius: 10px;
}
.uni_controls label slider:before {
position: absolute;
content: "";
height: 27px;
width: 27px;
left: 4px;
bottom: 4px;
background-color: red;
transition: .4s;
border-radius: 8px;
}
.uni_controls label input:checked+slider {
background-color: white;
}
.uni_controls label input:focus+slider {
box-shadow: 0 0 1px pink;
}
.uni_controls label input:checked+slider:before {
transform: translateX(115px);
}
slider:after {
content: 'OFF';
color: black;
display: block;
position: absolute;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
font-size: 10px;
font-family: Verdana, sans-serif;
}
.uni_controls label input:checked+slider:after {
content: 'ON';
}

<div class="uni_controls">
<input placeholder="THIS IS TEST TB" />
<label>
<input type="checkbox">
<slider>
</label>
<input placeholder="THIS IS TEST TB" />
<input placeholder="THIS IS TEST TB" />
<label>
<input type="checkbox">
<slider>
</label>
<label>
<input type="checkbox">
<slider>
</label>
&#13;
答案 0 :(得分:1)
只需将vertical-align: top;
添加到.uni_controls input
.uni_controls {
margin: 5px;
background-color: orange;
}
.uni_controls input {
vertical-align: top;
width: 150px;
height: 35px;
box-sizing: border-box;
border-radius: 10px;
border: 1px solid #00c1ff;
color: #00c1ff;
font-size: 10px;
outline: none;
text-align: center;
background-color: white;
margin: 2.5px;
}
.uni_controls label {
position: relative;
display: inline-block;
width: 150px;
height: 35px;
outline: none;
border-radius: 10px;
border: 1px solid #00c1ff;
margin: 2.5px;
}
.uni_controls label input {
display: none;
}
.uni_controls label slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: white;
transition: .4s;
border-radius: 10px;
}
.uni_controls label slider:before {
position: absolute;
content: "";
height: 27px;
width: 27px;
left: 4px;
bottom: 4px;
background-color: red;
transition: .4s;
border-radius: 8px;
}
.uni_controls label input:checked+slider {
background-color: white;
}
.uni_controls label input:focus+slider {
box-shadow: 0 0 1px pink;
}
.uni_controls label input:checked+slider:before {
transform: translateX(115px);
}
slider:after {
content: 'OFF';
color: black;
display: block;
position: absolute;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
font-size: 10px;
font-family: Verdana, sans-serif;
}
.uni_controls label input:checked+slider:after {
content: 'ON';
}
<div class="uni_controls">
<input placeholder="THIS IS TEST TB" />
<label>
<input type="checkbox">
<slider>
</label>
<input placeholder="THIS IS TEST TB" />
<input placeholder="THIS IS TEST TB" />
<label>
<input type="checkbox">
<slider>
</label>
<label>
<input type="checkbox">
<slider>
</label>