我有一个我设置的最大宽度和黄色背景的 div。在那个 div 中,我放置了两组单选按钮(每组 5 个按钮),每组都有一个关联的标签。
我不希望集合在单选按钮之间或关联文本和单选按钮之间分成两行。所以我在每个集合的范围内使用“空白:nowrap”。另一方面,如果有两个很长的集合,一个接一个,我希望第二个集合自动转到下一行。
我看到的很有趣。我有一个黄色背景的 div 居中在我的屏幕上,但两个单选按钮集在同一行。最右边的单选按钮集从黄色区域开始,但延伸超过它,进入背景。我做了一个 jsfiddle 来演示,它位于: https ://jsfiddle.net/03jLe0x1/ 代码也如下:
.radiospan {
font-family: Verdana;
}
.checkspan {
white-space: nowrap;
font-family: Verdana;
}
#newDivCenter {
background-color: yellow;
text-align: center;
min-width:788px;
max-width:840px;
}
<div id="newDivCenter"><span class="checkspan"><input type="checkbox" id="chk0" name="mychecks0" value="1">
Audible?</span><span> </span><span class="checkspan"><input type="checkbox" id="chk1" name="mychecks1" value="1">Musical?
</span><span> </span><span style="white-space: nowrap;"><span>Does this music transport you to heaven?
(1 for yuk, 5 for wow!)</span><span class="radiospan"><input type="radio" id="rad_1" name="myradios0" value="1">1</span>
<span class="radiospan"><input type="radio" id="rad_2" name="myradios0" value="2">2</span><span class="radiospan">
<input type="radio" id="rad_3" name="myradios0" value="3">3</span><span class="radiospan"><input type="radio" id="rad_4" name="myradios0" value="4">4</span><span class="radiospan"><input type="radio" id="rad_5" name="myradios0" value="5">5</span></span><span> </span><span style="white-space: nowrap;"><span>Are you now a believer in God?
(1 for not really, 5 for yeah!)</span><span class="radiospan"><input type="radio" id="rad_1" name="myradios1" value="1">1</span>
<span class="radiospan"><input type="radio" id="rad_2" name="myradios1" value="2">2</span><span class="radiospan">
<input type="radio" id="rad_3" name="myradios1" value="3">3</span><span class="radiospan"><input type="radio" id="rad_4"
name="myradios1" value="4">4</span><span class="radiospan"><input type="radio" id="rad_5" name="myradios1" value="5">5</span></span><span> </span><br style="clear: both;"><select id="mydropdown0">
<option value="0">Please Select religion</option><option value="318">Jewish</option><option value="319">Hindu</option>
<option value="320">Christian</option><option value="321">Muslim</option><option value="322">Atheist</option><option value="323">Other</option></select><span> </span></div>