我将CSSdisplay
属性与和值结合使用table
,以表格的形式布局文档。table-row
table-cell
通常(如您在代码中所见),表格中单元格的大小与包含的内容有关(直到我们提供硬编码的尺寸值。
但我想table-cell
在第二个(等等)■table-row
具有相同的宽度对应的table-cell
从第一table-row
。因此,第一宽度table-cell
的第二行中是一样的第一宽度table-cell
在第一table-row
。是否有可能?
我想这样做而不必在第二个和后续的s中添加pixel
margin
或其他padding
属性table-row
。我只希望它width
使单元格位于其上方。
因此,最后,一列的宽度将等于该列中最宽的单元格的宽度。
我怎样才能做到这一点?
这是小提琴。在代码中,三行具有不同的颜色。
代码:
<div style="display:table;">
<div style="background-color:#d9a4f4; display:table-row;">
<label style="display:table-cell; padding-left:10px; padding-right:10px;">Inferrable</label>
<label style="display:table-cell; padding-left:10px; padding-right:10px;">Not inferrable</label>
</div>
<div style="background-color:#7cbfdd; display:table-row;">
<input type="radio" name="radio_group1" value="0" style="display:table-cell;">
<input type="radio" name="radio_group1" value="0" style="display:table-cell;">
<label style="display:table-cell;">I am the label for the first group of radio buttons. I am the label for the first group of radio buttons. I am the label for the first group of radio buttons. I am the label for the first group of radio buttons. I am the label for the first group of radio buttons. </label>
</div>
<div style="background-color:#e8c277; display:table-row;">
<input type="radio" name="radio_group2" value="0" style="display:table-cell;">
<input type="radio" name="radio_group2" value="1" style="display:table-cell;">
<label style="display:table-cell;">I am the label for the second group of radio buttons. I am the label for the second group of radio buttons. I am the label for the second group of radio buttons. </label>
</div>
</div>
如果将单元格添加到第一行,然后将输入内容包装在一个跨度中:
<div style="display:table;">
<div style="background-color:#d9a4f4; display:table-row;">
<label style="display:table-cell; padding-left:10px; padding-right:10px;">Inferrable</label>
<label style="display:table-cell; padding-left:10px; padding-right:10px;">Not inferrable</label>
<span style="display:table-cell;"></span>
</div>
<div style="background-color:#7cbfdd; display:table-row;">
<span style="display:table-cell; text-align:center;"><input type="radio" name="radio_group1" value="0" style="display:table-cell;"></span>
<span style="display:table-cell; text-align:center;"><input type="radio" name="radio_group1" value="0" style="display:table-cell;"></span>
<label style="display:table-cell;">I am the label for the first group of radio buttons. I am the label for the first group of radio buttons. I am the label for the first group of radio buttons. I am the label for the first group of radio buttons. I am the label for the first group of radio buttons.</label>
</div>
<div style="background-color:#e8c277; display:table-row;">
<span style="display:table-cell; text-align:center;"><input type="radio" name="radio_group2" value="0" style="display:table-cell;"></span>
<span style="display:table-cell; text-align:center;"><input type="radio" name="radio_group2" value="1" style="display:table-cell;"></span>
<label style="display:table-cell;">I am the label for the second group of radio buttons. I am the label for the second group of radio buttons. I am the label for the second group of radio buttons.</label>
</div>
</div>
您应该能够实现所需的功能-示例
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句