【发布时间】:2021-06-20 12:10:05
【问题描述】:
我在 chat_bubble 父 div 中有一些文本和按钮。如果文本太多,或者屏幕太小,文本和按钮会延伸到父容器之外。
我需要 btn-grid 具有问题容器 20% 的固定高度,并让问题文本填充剩余空间。我需要做什么?
这是一个代码笔:
https://codepen.io/TheNomadicAspie/pen/JjWVbKJ
这是我的 CSS:
*, *::before, *::after {
box-sizing: border-box;
font-family: 'Benne', serif;
font-size: 10vh;
color: black;
line-height: 1.25;
}
:root {
--hue-neutral: 200;
}
body {
padding: 0;
margin: 0;
display: flex;
width: 100vw;
height: 100vh;
justify-content: center;
align-items: center;
background-color: black;
}
.container {
width: 90%;
height: 90%;
border-radius: 5px;
padding: 10px;
}
.btn-grid {
display: grid;
grid-template-columns: repeat(3, auto);
gap: 10px;
margin: 20px 0;
height: 20%;
}
.btn {
background-color: purple;
border-radius: 5px;
padding: 5px 10px;
color: white;
outline: none;
font-family: 'Fjalla One', sans-serif;
font-size: 5vh;
}
.btn:hover {
border-color: black;
}
.start-btn, .next-btn {
font-size: 1.5rem;
font-weight: bold;
padding: 10px 20px;
}
.controls {
display: flex;
justify-content: center;
align-items: center;
}
.hide {
display: none;
}
#main {
width: 90%;
height: 90%;
overflow: hidden;
}
#chat_bubble {
width: 70%;
height: 70%;
background: ghostwhite !important;
float: left;
}
#character_image {
max-height: 30vh;
object-fit: cover;
background: #ffffff;
float: right;
overflow: visible;
}
#question-text {
object-fit: cover;
overflow: visible;
}
【问题讨论】:
-
如果按钮前有多行问题文本,是否希望带有文本和按钮的问题容器可滚动?
-
不,无论有多少文本,我都需要字体大小来适应大小。
标签: javascript html css