Nowrap /输入后不要断行

ari*_*iel 8 html css

如果我有几个输入(无线电或选项),然后是他们的标签,所有都在同一条线上.我怎么做它所以它不会在收音机后断线,但如果需要在标签后断开.

<input type="radio" id="i1"/><label for="i1">First radio</label>
<input type="radio" id="i2"/><label for="i2">Second radio</label>
<input type="radio" id="i3"/><label for="i3">Third radio</label>
Run Code Online (Sandbox Code Playgroud)

我能想到的都包裹的input,并labelspannowrap,但不知道是否有另一种方式.

Sha*_*ard 15

这应该做的伎俩:

#MyDiv {width: 250px;}
Run Code Online (Sandbox Code Playgroud)
<div id="MyDiv">
    <nobr><input type="radio" id="i1"/><label for="i1">First radio</label></nobr>
    <nobr><input type="radio" id="i2"/><label for="i2">Second radio</label></nobr>
    <nobr><input type="radio" id="i3"/><label for="i3">Third radio</label></nobr>
</div>
Run Code Online (Sandbox Code Playgroud)

<nobr>标签将确保突破将不会按钮和标签之间发生.

CSS方式也是可能的,用另一个包装它<span>并使用white-space: nowrap;应该工作正常.