Сделать так, чтобы текст заполнял только оставшееся пространство в ячейке таблицыCSS

Разбираемся в CSS
Ответить Пред. темаСлед. тема
Гость
 Сделать так, чтобы текст заполнял только оставшееся пространство в ячейке таблицы

Сообщение Гость »


Preconditions: I am limited to old browsers (around Chrome 25), which do not support a lot of CSS features. Also, the table structure with 3 columns needs to remain, and the first column should not take more space, than it needs.
Goal: I have an info element, which specifies the overall width and a red box within the cell, which already takes up some space. Furthermore, I want the text element to fill the remaining space, without pushing the red box out of the boundaries. Note, that the parent width and the box width could be dynamic values, depending on the screen resolution. I tried to wrap the according cell in another flex box combined with "flex: 1 1 0" and many other things, and ChatGPT also had no answer.
Do you have a solution? Or is it not solvable with the requirements?

Код: Выделить всё

.info {
width: 600px; /* dynamic */
background: lightgray;
}

.container {
background: gray;
}

.table {
display: table;
}

.row {
display: table-row;
}

.row :first-child {
border-right: solid black 20px;
}

.cell {
display: table-cell;
}

.flex {
display: flex;
}

.box {
width: 300px; /* dynamic */
background: red;
}

.text {
white-space: nowrap; /* needs to fill the remaining space, without pushing the box out of its parent */
}

Код: Выделить всё




1.1
1.2
1.3


2.1


This is a text, too long to fit inside the container



2.3





EDIT: Each row can only consist of a single line, thus white-space: nowrap is required. That part of the text, that needs to be cut of, should be hidden with overlap: hidden.
Current Layout:
Изображение
Expected Layout:
Изображение



Источник: https://stackoverflow.com/questions/781 ... table-cell
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «CSS»