【发布时间】:2011-09-30 23:14:28
【问题描述】:
我有一个复选框网格,其中每个单元格都有固定的宽度,每个复选框前面都有一个小图像。在标签文本太长的情况下,我很难让文本在复选框下方换行。
参考上面的截图,我希望“换行的文本”与复选框对齐,而不是像这样换行:
我已经使用我当前的标记和样式设置了 fiddle。我无法更改的是 HTML 结构,但任何 CSS 更改都可以。
这是一个代码sn-p:
.checkbox-list {
}
img.placeholder{
width:16px;
height:16px;
background-color:lightblue;
}
td {
padding:2px;
width:150px;
vertical-align:top;
}
label {
/*display:inline-block;*/
}
<table class="checkbox-list">
<tbody><tr>
<td>
<img class="placeholder"/>
<label>
<input type="checkbox"/>
<span>Some really long text that wraps</span></label></td>
<td>
<img class="placeholder"/>
<label>
<input type="checkbox"/>
<span>Foo</span></label></td>
<td>
<img class="placeholder"/>
<label>
<input type="checkbox"/>
<span>Foo</span></label></td>
</tr><tr>
<td>
<img class="placeholder"/>
<label>
<input type="checkbox"/>
<span>Foo</span></label></td>
<td>
<img class="placeholder"/>
<label>
<input type="checkbox"/>
<span>Foo</span></label></td>
<td>
<img class="placeholder"/>
<label>
<input type="checkbox"/>
<span>Foo</span></label></td>
</tr>
</tbody></table>
【问题讨论】:
-
嗯...我没有看到浅蓝色框。
-
@AllenLiu 你用的是什么浏览器?我在 chrome 和 IE 上测试过。
-
我在 Windows 7 上的 FF v7 上使用。我只是添加了一个 'float:left;'到
img.placeholder,我现在可以看到这些框了。