gpt4 book ai didi

html - 如何防止最后一个 flex 元素溢出父级

转载 作者:太空宇宙 更新时间:2023-11-04 07:39:28 26 4
gpt4 key购买 nike

我想弄清楚如何使我的列表中的最后一个 flex 元素不会扩展到容器底部之外。它有一个 contenteditable div,当有人输入多行文本时我需要展开它。

主要的 flex 元素是一列中的 3 个 div,标题栏是 100% 宽度,内容容器是 100% 宽度,可以增长和收缩,页脚是 flex 并且应该导致内部容器收缩。

目前,当您在 div.detail-chat-input 中输入多于一行的文本时,它确实会向上扩展,但也会将按钮向下推。

像这样:

Footer buttons overflowing the container

* {
box-sizing: border-box;
}

.panel-popover-window {
background-color: grey;
border-bottom: 1px solid black;
display: flex;
flex-direction: column;
}

.panel-popover-title-bar {
border: 1px solid black;
width: 100%;
height: 50px;
line-height: 50px;
padding: 0 20px;
position: relative;
}

.panel-popover-content {
display: flex;
flex-direction: row;
flex-grow: 1;
flex-shrink: 1;
padding: 5px;
min-height: 0;
overflow-y: scroll;
}

.panel-popover-column-2 {
display: flex;
flex-direction: column;
flex: 0 0 50%;
}

.panel-popover-panel {
border: 1px solid #e0e0e0;
margin: 5px;
background-color: #fff;
}

.panel-popover-panel-title {
display: block;
border-bottom: 1px solid black;
width: 100%;
height: 50px;
padding: 0 10px;
position: relative;
}

.panel-popover-footer {
min-height: 60px;
padding: 0 10px;
}

.panel-popover-footer-content {
position: relative;
}

.panel-popover-footer-button-bar {
width: 100%;
height: 60px;
}

.panel-popover-close-button {
border: 1px solid black;
width: 83px;
height: 37px;
float: right;
margin-top: 15px;
}

.detail-chat-input {
min-height: 48px;
border: 1px solid black;
border-radius: 5px;
background-color: #fff;
padding: 10px;
width: 100%;
font-size: 15px;
line-height: 30px;
}

.detail-activity-scrollable {
overflow-y: scroll;
height: calc(100% - 50px);
}
.detail-message-container {
min-height: 800px;
}

.panel-popover-panel.activity {
max-height: 685px;
overflow-y: hidden;
position: relative;
}
<html>
<head>
</head>
<body>
<div class="panel-popover-window detail-popover" style="width: 1200px; height: 875px;">
<div class="panel-popover-title-bar">
<span class="panel-popover-title-bar-text">Popover Title</span>
<div class="panel-popover-title-bar-close"></div>
</div>
<div class="panel-popover-content">
<div class="panel-popover-column panel-popover-column-2">
<div class="panel-popover-panel submission-info">
<div class="panel-popover-panel-title">Title 1</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
</div>
<div class="panel-popover-panel statistics">
<div class="panel-popover-panel-title">Title 2</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
</div>
</div>
<div class="panel-popover-column panel-popover-column-2">
<div class="panel-popover-panel activity">
<div class="panel-popover-panel-title">Title 3</div>
<div class="detail-activity-scrollable">
<div class="detail-message-container">
<div class="ad-approval-panel-line">Data</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel-popover-footer">
<div class="panel-popover-footer-content">
<textarea class="detail-chat-input" placeholder="Send Message" data-emojiable="converted" style="display: none;" data-id="8ff80f0d-85e3-4ac4-acbf-c950fffbc1a4" data-type="original-input"></textarea>
<div class="emoji-wysiwyg-editor detail-chat-input parent-has-scroll" placeholder="Send Message" contenteditable="true"></div>
<div class="panel-popover-footer-button-bar">
<button class="detail-admin-control detail-approve" disabled="">Button 1</button>
<button class="detail-admin-control detail-disapprove">Button 2</button>
<div class="panel-popover-close-button">Close</div>
</div>
</div>
</div>
</div>
</body>
</html>

最佳答案

.panel-popover-window容器一个height: 100%;

* {
box-sizing: border-box;
}

.panel-popover-window {
background-color: grey;
border-bottom: 1px solid black;
display: flex;
flex-direction: column;
width: 1200px;
height: 100%;
}

.panel-popover-title-bar {
border: 1px solid black;
width: 100%;
height: 50px;
line-height: 50px;
padding: 0 20px;
position: relative;
}

.panel-popover-content {
display: flex;
flex-direction: row;
flex-grow: 1;
flex-shrink: 1;
padding: 5px;
min-height: 0;
overflow-y: scroll;
}

.panel-popover-column-2 {
display: flex;
flex-direction: column;
flex: 0 0 50%;
}

.panel-popover-panel {
border: 1px solid #e0e0e0;
margin: 5px;
background-color: #fff;
}

.panel-popover-panel-title {
display: block;
border-bottom: 1px solid black;
width: 100%;
height: 50px;
padding: 0 10px;
position: relative;
}

.panel-popover-footer {
min-height: 60px;
padding: 0 10px;
}

.panel-popover-footer-content {
position: relative;
}

.panel-popover-footer-button-bar {
width: 100%;
height: 60px;
}

.panel-popover-close-button {
border: 1px solid black;
width: 83px;
height: 37px;
float: right;
margin-top: 15px;
}

.detail-chat-input {
min-height: 48px;
border: 1px solid black;
border-radius: 5px;
background-color: #fff;
padding: 10px;
width: 100%;
font-size: 15px;
line-height: 30px;
}

.detail-activity-scrollable {
overflow-y: scroll;
height: calc(100% - 50px);
}
.detail-message-container {
min-height: 800px;
}

.panel-popover-panel.activity {
max-height: 685px;
overflow-y: hidden;
position: relative;
}
<html>
<head>
</head>
<body>
<div class="panel-popover-window detail-popover">
<div class="panel-popover-title-bar">
<span class="panel-popover-title-bar-text">Popover Title</span>
<div class="panel-popover-title-bar-close"></div>
</div>
<div class="panel-popover-content">
<div class="panel-popover-column panel-popover-column-2">
<div class="panel-popover-panel submission-info">
<div class="panel-popover-panel-title">Title 1</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
</div>
<div class="panel-popover-panel statistics">
<div class="panel-popover-panel-title">Title 2</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
<div class="ad-approval-panel-line">Data</div>
</div>
</div>
<div class="panel-popover-column panel-popover-column-2">
<div class="panel-popover-panel activity">
<div class="panel-popover-panel-title">Title 3</div>
<div class="detail-activity-scrollable">
<div class="detail-message-container">
<div class="ad-approval-panel-line">Data</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel-popover-footer">
<div class="panel-popover-footer-content">
<textarea class="detail-chat-input" placeholder="Send Message" data-emojiable="converted" style="display: none;" data-id="8ff80f0d-85e3-4ac4-acbf-c950fffbc1a4" data-type="original-input"></textarea>
<div class="emoji-wysiwyg-editor detail-chat-input parent-has-scroll" placeholder="Send Message" contenteditable="true"></div>
<div class="panel-popover-footer-button-bar">
<button class="detail-admin-control detail-approve" disabled="">Button 1</button>
<button class="detail-admin-control detail-disapprove">Button 2</button>
<div class="panel-popover-close-button">Close</div>
</div>
</div>
</div>
</div>
</body>
</html>

关于html - 如何防止最后一个 flex 元素溢出父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48657049/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com