gpt4 book ai didi

容器内的 HTML 复选框标签未按预期显示

转载 作者:太空宇宙 更新时间:2023-11-03 20:19:40 25 4
gpt4 key购买 nike

以下 HTML 代码尝试在 <div></div> 中显示复选框容器。

<div style="overflow: auto; width: auto; display:block; max-height:130px; max-width:200px; background-color: #FFF; height: auto; border: 1px double #336699; padding-left: 2px;">

<label for="chk12" style='white-space: nowrap;'>
<input type='checkbox' id="chk12" name='chk_colours' value="12" class='validate[required] text-input text'>
<div style='background-color:#FF8C00; width: 180px;' title="darkorange">&nbsp;&nbsp;</div>
</label>

<label for="chk11" style='white-space: nowrap;'>
<input type='checkbox' id="chk11" name='chk_colours' value="11" class='validate[required] text-input text'>
<div style='background-color:#D9D919; width: 180px;' title="brightgold">&nbsp;&nbsp;</div>
</label>

<label for="chk10" style='white-space: nowrap;'>
<input type='checkbox' id="chk10" name='chk_colours' value="10" class='validate[required] text-input text'>
<div style='background-color:#76EE00; width: 180px;' title="chartreuse2">&nbsp;&nbsp;</div>
</label>

<label for="chk9" style='white-space: nowrap;'>
<input type='checkbox' id="chk9" name='chk_colours' value="9" class='validate[required] text-input text'>
<div style='background-color:#2E0854; width: 180px;' title="indigo">&nbsp;&nbsp;</div>
</label>

<label for="chk8" style='white-space: nowrap;'>
<input type='checkbox' id="chk8" name='chk_colours' value="8" class='validate[required] text-input text'>
<div style='background-color:#292929; width: 180px;' title="gray16">&nbsp;&nbsp;</div>
</label>
</div>

它显示的内容可以在下面snap shot中看到.

enter image description here

可以看出,使用以下<div>显示的各种颜色条纹标签

<div style='background-color:#FF8C00; width: 180px;' title="darkorange">&nbsp;&nbsp</div>

显示在各自的复选框下方,即使我使用的是 white-space: nowrap;,这些复选框也应该以直线显示样式属性。

如何在一条直线上显示每个条纹及其各自的复选框?


它在我的一个问题本身中得到了解释,但在那个问题中,每个复选框都有一个文本标签来代替这些颜色条纹。 Here这是。我尝试按照该问题的公认答案中提到的去做,但在这种情况下无济于事。

最佳答案

您已经使用DIV 来标记标签。默认情况下,DIV 显示为 block 元素。只需将其设置为 display: inline;display: inline-block;。或者使用另一个元素——例如 SPAN

关于容器内的 HTML 复选框标签未按预期显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13352797/

25 4 0