gpt4 book ai didi

html - 是否可以将内容插入 DIV 但 DIV 保持相同大小?

转载 作者:行者123 更新时间:2023-11-28 04:00:59 24 4
gpt4 key购买 nike

我用三个 DIV 元素填充视口(viewport)。所有三个 DIV 都有 position: absoluteleft: 0pxwidth: 100%

顶部 DIV 高度:10%,中间 DIV 高度:88%,底部 DIV 高度:2% .

例如,有没有办法让我在顶部 DIV 中插入文本,并使其保持在 10% 的高度?因为 10% 足够大,可以在 DIV 不增长的情况下包含文本……但 DIV 无论如何都会增长。

HTML:

<html>
<head>
<link rel='stylesheet' href='css/style.css' />
</head>
<body>

<div id="bodyWrap">
<div id="header" class="box">
a
</div>
<div id="mid" class="box">
a
</div>
<div id="footer" class="box">
a
</div>
</div>

</body>
</html>

CSS:

@font-face{ 
font-family: gab;
src: url('gabriola.ttf');
}

#bodyWrap
{
/*If ever necessary.*/
text-align: center;
font-family: gab;
}

.box
{
background-color: rgb(216, 179, 126);
position: absolute;
width: 100%;
left: 0px;
}

#header
{
height: 10%;
top: 0px;
}

#mid
{
height: 88%;
top: 10%;
}

#footer
{
height: 2%;
bottom: 0px;
}

最佳答案

只需将 overflow: auto; 添加到 div

.editable {
height: 200px;
width: 500px;
border: 1px solid #000;
overflow: auto;
margin: 20px auto;
}
<div class='editable' contenteditable="true">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum.
</div>

关于html - 是否可以将内容插入 DIV 但 DIV 保持相同大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43206618/

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