0

演示

我有以下html...

<div>
<input type="radio" value="some value">some text here<br />
<input type="radio" value="some value">some text here and long<br />
</div>

div 的宽度为 110 像素。当一些文本低于它时,它应该像这样在同一行。

o some text
o some text
  and logn
4

3 回答 3

1

这可以通过在代码中添加一些 CSS 来完成。

HTML:

<div>
    <input type="radio" value="some value" />
    <label>some text here</label>
    <br />
    <input type="radio" value="some value" />
    <label>some text here and long</label>
    <br />
</div>

CSS:

div {
    width: 110px;
}
input[type="radio"] {
    float: left;
}
label {
    float: left;
    width: 80%;
}

检查这个JSFiddle

于 2013-06-18T08:42:06.450 回答
0

试着把它放在这样的桌子上:

<div style="width: 110px;">
    <table>
        <tr>
            <td><input type="radio" value="some value"></td>
            <td>some text here</td>
        </tr>
        <tr>
            <td><input type="radio" value="some value"></td>
            <td>some text here and long</td>
        </tr>
    </table>
</div>
于 2013-06-18T08:37:21.587 回答
0

这对我来说似乎是唯一可能的解决方案。

演示

div{
    width: 110px;
    position:relative;
    margin-left: 15px;
}
input[type="radio"]{
    position:absolute;
    left: -20px;
}

或者

演示

div{
    width: 110px;
    position:relative;
    padding-left: 20px;
}
input[type="radio"]{
    position:absolute;
    left: 0;
}
于 2013-06-18T09:18:10.670 回答