Я использую свойство CSS display
со значениями table
, table-row
и table-cell
для макета мой документ в виде таблицы.
Обычно (как вы можете видеть в коде) размер ячеек в таблице связан с содержимым, которое содержит (пока мы не предоставим жестко запрограммированные значения измерения.
Но я хочу, чтобы table-cell
во втором (и так далее) table-row
имели ту же ширину, что и соответствующие table-cell
из первого table-row
. Таким образом, ширина 1-го table-cell
во втором ряду такая же, как у ширина 1-го table-cell
в первом table-row
. Является ли это возможным?
Я хочу сделать это без добавления свойств pixel
margin
или padding
и т. д. во второй и последующие table-row
s. Я просто хочу, чтобы он получил 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>
th
иscope
s, установленными для первой строки. - person Pete   schedule 27.08.2014width
заключается в том, что в первой строке иногда будут слова размером с «Да» иNo
в качестве меток, а иногдаinferrable
иNot inferrable
. Так, например. если я сделаю этоwidth:150px
с учетомNot Inferrable
, оно будет слишком широким для словаNo
- person Solace   schedule 27.08.2014table-cell
в первыйtable-row
, это решит проблему? - person Solace   schedule 27.08.2014