gpt4 book ai didi

html - 单选按钮不会在文本旁边

转载 作者:太空宇宙 更新时间:2023-11-04 00:57:17 24 4
gpt4 key购买 nike

我有两个彼此相邻的自定义单选按钮。但它在具有前排类型和标题的 block 中排名第三。两者在 css 中都有 display: inline-block; 但单选按钮仍然位于文本 block 下方。我不知道如何让他们像其他人一样挨在一起。

/*radio button yes no*/
.switch-field {
font-family: "Lucida Grande", Tahoma, Verdana, sans-serif;
padding: 40px;
overflow: hidden;
margin-left: 225px;
}



.switch-field input {
position: absolute !important;
clip: rect(0, 0, 0, 0);
height: 1px;
width: 1px;
border: 0;
overflow: hidden;
}

.switch-field label {
float: left;
}

.switch-field label {
display: inline-block;
width: 100px;
background-color: white;
color: rgba(0, 0, 0, 0.6);
font-size: 14px;
font-weight: normal;
text-align: center;
text-shadow: none;
padding: 6px 14px;
border: 1px solid #b70000;
-webkit-transition: all 0.1s ease-in-out;
-moz-transition: all 0.1s ease-in-out;
-ms-transition: all 0.1s ease-in-out;
-o-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}

.switch-field label:hover {
cursor: pointer;
}

.switch-field input:checked + label {
background-color: #b70000;;
color:white;
}

.switch-field label:first-of-type {
border-radius: 0px 0 0 0px;
}

.switch-field label:last-of-type {
border-radius: 0 0px 0px 0;
}
/*radio button yes no*/

/*block*/
.block label { display: inline-block; width: 140px; text-align: right; }
<div class="CalculatorLeft" style="padding-left: 29px;"id="alles">
<h2 style="color:#b70000;">Bereken Prijs</h2>
<div class="block">
<label>Aantal vierkante meters</label>
<input type="text" style="border:0px;border-bottom:1px solid #b70000;margin-left: 92px;width:200px;" />
</div><br>
<div class="block">
<label>V-naden aanwezig</label>
<select name="cars" class="" style="border:0px;border-bottom:1px solid #b70000;margin-left: 128px;width:200px;">
<option value="behandeling" selected>Soort behandeling</option>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
</div><br>
<div class="block">
<label>Soort behandeling</label>
<div class="switch-field">
<input type="radio" id="switch_left" name="switch_2" value="yes" checked/>
<label for="switch_left">Yes</label>
<input type="radio" id="switch_right" name="switch_2" value="no" />
<label for="switch_right">No</label>
</div>
</div><br>
<div class="block">
<label>Postcode & Huisnummer</label>
<input type="text" style="border:0px;border-bottom:1px solid #b70000;margin-left: 89px;width:200px;" />
</div>

</div>

最佳答案

您应该尝试删除“是/否”单选输入的父元素上的任何边距和填充,因为此“容器”导致元素从标签移开。

请参阅解决方案片段:

/*radio button yes no*/

.switch-field {
font-family: "Lucida Grande", Tahoma, Verdana, sans-serif;
/*padding: 40px;*/
overflow: hidden;
/*margin-left: 225px;*/
display: inline-block;
vertical-align: middle;
}

.switch-field input {
position: absolute !important;
clip: rect(0, 0, 0, 0);
height: 1px;
width: 1px;
border: 0;
overflow: hidden;
}

.switch-field label {
float: left;
}

.switch-field label {
display: inline-block;
width: 100px;
background-color: white;
color: rgba(0, 0, 0, 0.6);
font-size: 14px;
font-weight: normal;
text-align: center;
text-shadow: none;
padding: 6px 14px;
border: 1px solid #b70000;
-webkit-transition: all 0.1s ease-in-out;
-moz-transition: all 0.1s ease-in-out;
-ms-transition: all 0.1s ease-in-out;
-o-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}

.switch-field label:hover {
cursor: pointer;
}

.switch-field input:checked+label {
background-color: #b70000;
;
color: white;
}

.switch-field label:first-of-type {
border-radius: 0px 0 0 0px;
}

.switch-field label:last-of-type {
border-radius: 0 0px 0px 0;
}


/*radio button yes no*/

.block label {
display: inline-block;
width: 140px;
text-align: right;
}
<div class="CalculatorLeft" style="padding-left: 29px;" id="alles">
<h2 style="color:#b70000;">Bereken Prijs</h2>
<div class="block">
<label>Aantal vierkante meters</label>
<input type="text" style="border:0px;border-bottom:1px solid #b70000;margin-left: 92px;width:200px;" />
</div><br>
<div class="block">
<label>V-naden aanwezig</label>
<select name="cars" class="" style="border:0px;border-bottom:1px solid #b70000;margin-left: 128px;width:200px;">
<option value="behandeling" selected>Soort behandeling</option>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
</div><br>
<div class="block">
<label>Soort behandeling</label>
<div class="switch-field">
<input type="radio" id="switch_left" name="switch_2" value="yes" checked/>
<label for="switch_left">Yes</label>
<input type="radio" id="switch_right" name="switch_2" value="no" />
<label for="switch_right">No</label>
</div>
</div><br>
<div class="block">
<label>Postcode & Huisnummer</label>
<input type="text" style="border:0px;border-bottom:1px solid #b70000;margin-left: 89px;width:200px;" />
</div>

</div>

查看您的 .switch-field 类以进行更改。您也可以为其添加边距顶部以正确定位它。如果您需要更多帮助,请告诉我。

JSFiddle

关于html - 单选按钮不会在文本旁边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54304561/

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