Хорошо. Рассмотрим, у меня есть таблица с 3 столбцами. «Обычно» каждый столбец должен занимать 1/3 страницы. Однако если один из данных столбца становится слишком большим, а другие столбцы имеют дополнительное пространство, он должен «согнуться», и столбец должен занять оставшееся пространство.
Однако это все равно должна быть «таблица»: как в столбцах и границах строк необходимо выровнять.
При использовании наивных флекс-боксов я пробовал сначала подход с использованием строки и столбца. Однако у обоих есть проблема в том, что «внутренний» flexbox может растягиваться, но эта информация теряется в других flex-боксах.
Я попытался решить ее ниже, используя оба метода: но, как вы можете видеть, это не работает:
.bordered{
border-width: 1px;
border-color: black;
border-style: solid;
}
.main {
display: block;
position: relative;
}
.row {
display: flex;
position: relative;
width: 100%;
}
.cell {
flex: 1 1 auto;
max-width: 75%;
}
<div class="main bordered">
<div class="row">
<div class="cell bordered">
first
</div>
<div class="cell bordered">
second
</div>
<div class="cell bordered">
third
</div>
</div>
<div class="row">
<div class="cell bordered">
first
</div>
<div class="cell bordered">
This is text that will increase the width of the cell.
</div>
<div class="cell bordered">
third
</div>
</div>
<div class="row">
<div class="cell bordered">
first
</div>
<div class="cell bordered">
This is text that will increase the width of the cell. Not only that, but due to the amount of text it also increases the height of a row. This isn't a problem with this setup. But had we chosen to use a column-first approach this cell would destroy any "row" layout.
</div>
<div class="cell bordered">
third
</div>
</div>
</div>
Можно ли это сделать? Или я должен отказаться от этого?