Высота гибкого контейнера определяется конкретным дочерним элементомCSS

Разбираемся в CSS
Ответить Пред. темаСлед. тема
Anonymous
 Высота гибкого контейнера определяется конкретным дочерним элементом

Сообщение Anonymous »

На моей странице три элемента div рядом друг с другом. Один основной контент и два типа боковой панели. Все они имеют динамическое содержимое и не имеют фиксированной высоты.Я хочу, чтобы главный дочерний элемент определял высоту контейнера. И два контейнера боковой панели соответствуют этому. Таким образом, боковые панели должны быть настолько высокими, насколько это необходимо, но не выше основного дочернего элемента. (Если у них есть больше контента для отображения, то вместо этого они должны получить вертикальную полосу прокрутки)
В моем текущем решении у меня есть то, что высота контейнера определяется самым высоким ребенок. Это не то, чего я хочу.
В этом коде и блоке показана проблема:
https://codesandbox.io/p/sandbox/sideba ... -92pgchКак добиться того, чтобы высота контейнера определялась только основным дочерним элементом?
С уважением
Фрагменты кода:< /p>

.container {
display: flex;
align-items: flex-start;
}
.container .main-child {
flex-grow: 1;
background-color: salmon;
}
.container .sidebar {
min-width: 300px;
max-width: 300px;
overflow-y: auto;
}



Sidebar height problem

Currently, the container height is always determined by the largest flex
child (in the first example by the rightmost sidebar and in the second
example by the main-child).

What I want instead, is that only the main-child determines the height.

The sidebars should be only as high as needed for their content, but
not
larger than the main-child. And if one of the sidebars is
larger because of it's content, then it should have a scrollbar.


A wonderful serenity has taken possession of my entire soul, like these
sweet mornings of spring which I enjoy with my whole heart. I am alone,
and feel the charm of existence in this spot, which was created for the
bliss of souls like mine. I am so happy, my dear friend, so absorbed in
the exquisite sense of mere tranquil existence, that I neglect myA
wonderful serenity has taken possession of my entire soul, like these
sweet mornings of spring which I enjoy with my whole heart. I am alone,
and feel the charm of existence in this spot, which was created for the
bliss of souls like mine. I am so happy, my dear friend, so absorbed in
the exquisite sense of mere tranquil existence, that I neglect my like
these sweet mornings of spring which I enjoy with my whole heart. I am
alone, and feel the charm of existence in this spot, which was created
for the bliss of souls like mine. I am so happy, my dear friend, so
absorbed in the exquisite sense of mere tranquil existence, that I
neglect my. I am alone, and feel the charm of existence in this spot,
which was created for the bliss of souls like mine. I am so happy, my
dear friend, so absorbed in the exquisite sense of mere tranquil
existence, that I neglect my

A wonderful serenity has taken possession of my entire soul, like these
sweet mornings of spring which I enjoy with my whole heart.

A wonderful serenity has taken possession of my entire soul, like these
sweet mornings of spring which I enjoy with my whole heart. I am alone,
and feel the charm of existence in this spot, which was created for the
bliss of souls like mine. I am so happy, my dear friend, so absorbed in
the exquisite sense of mere tranquil existence, that I neglect my
talents. I should be incapable of drawing a single stroke at the present
moment; and yet I feel that I never was a greater artist than now. When,
while the lovely valley teems with vapour around me, and the meridian
sun strikes the upper surface of the impenetrable foliage of my trees,
and but a few stray gleams steal into the inner sanctuary,




A wonderful serenity has taken possession of my entire soul, like these
sweet mornings of spring which I enjoy with my whole heart. I am alone,
and feel the charm of existence in this spot, which was created for the
bliss of souls like mine. I am so happy, my dear friend, so absorbed in
the exquisite sense of mere tranquil existence, that I neglect my
talents. I should be incapable of drawing a single stroke at the present
moment; and yet I feel that I never was a greater artist than now. When,
while the lovely valley teems with vapour around me, and the meridian
sun strikes the upper surface of the impenetrable foliage of my trees,
and but a few stray gleams steal into the inner sanctuary, I throw
myself down among the tall grass by the trickling stream; and, as I lie
close to the earth, a thousand unknown plants are noticed by me: when I
hear the buzz of the little world among the stalks, and grow familiar
with the countless indescribable forms of the insects and flies, then I
feel the presence of the Almighty, who formed us in his own image, and
the breath A wonderful serenity has taken possession of my entire soul,
like these sweet mornings of spring which I enjoy with my whole heart. I
am alone, and feel the charm of existence in this spot, which was
created for the bliss of souls like mine. I am so happy, my dear friend,
so absorbed in the exquisite sense of mere tranquil existence, that I
neglect my talents. I should be incapable of drawing a single stroke at
the present moment; and yet I feel that I never was a greater artist
than now. When, while the lovely valley teems with vapour around me, and
the meridian sun strikes the upper surface of the impenetrable foliage
of my trees, and but a few stray gleams steal into the inner sanctuary,
I throw myself down among the tall grass by the trickling stream; and,
as I lie close to the earth, a thousand unknown plants are noticed by
me: when I hear the buzz of the little world among the stalks, and grow
familiar with the countless indescribable forms of the insects and
flies, then I feel the presence of the Almighty, who formed us in his
own image, and the breath A wonderful serenity has taken possession of
my entire soul, like these sweet mornings of spring which I enjoy with
my whole heart. I am alone, and feel the charm of existence in this
spot, which was created for the bliss of souls like mine. I am so happy,
my dear friend, so absorbed in the exquisite sense of mere tranquil
existence, that I neglect my talents. I should be incapable of drawing a
single stroke at the present moment; and yet I feel that I never was a
greater artist than now. When, while the lovely valley teems with vapour
around me, and the meridian sun strikes the upper surface of the
impenetrable foliage of my trees, and but a few stray gleams steal into
the inner sanctuary, I throw myself down among the tall grass by the
trickling stream; and, as I lie close to the earth, a thousand unknown
plants are noticed by me: when I hear the buzz of the little world among
the stalks, and grow familiar with the countless indescribable forms of
the insects and flies, then I feel the presence of the Almighty, who
formed us in his own image, and the breath A wonderful serenity has
taken possession of my entire soul, like these sweet mornings of spring
which I enjoy with my whole heart. I am alone, and feel the charm of
existence in this spot, which was created for the bliss of souls like
mine. I am so happy, my dear friend, so absorbed in the exquisite sense
of mere tranquil existence, that I neglect my talents. I should be
incapable of drawing a single stroke at the present moment; and yet I
feel that I never was a greater artist than now. When, while the lovely
valley teems with vapour around me, and the meridian sun strikes the
upper surface of the impenetrable foliage of my trees, and but a few
stray gleams steal into the inner sanctuary, I throw myself down among
the tall grass by the trickling stream; and, as I lie close to the
earth, a thousand unknown plants are noticed by me: when I hear the buzz
of the little world among the stalks, and grow familiar with the
countless indescribable forms of the insects and flies, then I feel the
presence of the Almighty, who formed us in his own image, and the breath

A wonderful serenity has taken possession of my entire soul, like these
sweet mornings of spring which I enjoy with my whole heart.

A wonderful serenity has taken possession of my entire soul, like these
sweet mornings of spring which I enjoy with my whole heart. I am alone,
and feel the charm of existence in this spot, which was created for the
bliss of souls like mine. I am so happy, my dear friend, so absorbed in
the exquisite sense of mere tranquil existence, that I neglect my
talents. I should be incapable of drawing a single stroke at the present
moment; and yet I feel that I never was a greater artist than now. When,
while the lovely valley teems with vapour around me, and the meridian
sun strikes the upper surface of the impenetrable foliage of my trees,
and but a few stray gleams steal into the inner sanctuary





Подробнее здесь: https://stackoverflow.com/questions/787 ... ific-child
Реклама
Ответить Пред. темаСлед. тема

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

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

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

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

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

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