gpt4 book ai didi

html - 如何使溢出-y : scroll account for border size

转载 作者:行者123 更新时间:2023-11-28 00:33:43 25 4
gpt4 key购买 nike

我想让 ul 的溢出帐户包含它所在的 div 的边界。

我尝试添加与边框标记具有相同 px 测量值的填充。

.resizable {
background: black;
width: 80%;
height: 50%;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
}

.resizable .resizers {
width: 100%;
height: 100%;
border: 3px solid #4286f4;
box-sizing: border-box;
}

.resizable .resizers .resizer {
width: 10px;
height: 10px;
border-radius: 50%; /* Magic to turn square into circle. */
background: white;
border: 3px solid #4286f4;
position: absolute;
}

.resizable .resizers .resizer.top-left {
left: -5px;
top: -5px;
cursor: nwse-resize;
}

.resizable .resizers .resizer.top-right {
right: -5px;
top: -5px;
cursor: nesw-resize;
}

.resizable .resizers .resizer.bottom-left {
left: -5px;
bottom: -5px;
cursor: nesw-resize;
}

.resizable .resizers .resizer.bottom-right {
right: -5px;
bottom: -5px;
cursor: nwse-resize;
}

#npc_events {
width: 100%;
height: 100%;
flex-grow: 1;
list-style: none;
margin: 0;
padding: 0;
border-bottom: 1px solid lightgrey;
overflow-y: scroll;
}

#npc_events li {
padding: 10px 10px 10px 10px;
color: white;
}
        <body>
<div id='div_npc_chat' class='resizable'>
<div class='resizers'>
<div class='resizer top-left'></div>
<div class='resizer top-right'></div>
<div class='resizer bottom-left'></div>
<div class='resizer bottom-right'></div>

<div class="chat-wrapper">
<form id="npc_chat-form">
<input id="npc_chat" autocomplete="off" title="chat"/>
<button id="npc_say">Say</button>
</form>
</div>
<ul id="npc_events"></ul>
</div>
</div>
</body>

我期待文本,它是 <li> <ul> 的元素包含在 <div> 中不出现在 div 的蓝色边框之上,但我明白了:

https://cdn.discordapp.com/attachments/401030271417188355/613446713629343756/unknown.png

最佳答案

您的列表溢出(或超出 div/出现在行的顶部)的原因是您将标签 #npc_events 设置为 100% 高度,这不考虑输入栏(聊天包装 div)。

一种解决方案是向 .resizers 类添加填充并计算 .chat-wrapper div 类的高度,从那里您可以将以下内容添加到 #npc_events div。

height: calc(100% - (height of chat-wrapper));

否则,我建议将 chat-wrapper 的高度设置为 wrapper div (.resizers) 的一定百分比,并将其余部分设置为列表。例如:

.resizers {padding: 10px;}
.chat-wrapper {height: 20%;}
#npc_events {height: 80%;}

这会让您得到想要的结果。

关于html - 如何使溢出-y : scroll account for border size,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57580106/

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