我有一个大的div,我想把内容放入.我想要div填充并具有最小高度,以便如果有太多文本,div它扩展下来以保持填充.但我也不希望它的高度低于100px.目前,当我运行此代码时,一些文本不属于div.
HTML:
<div id='content'>
<div>lots of text in here</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
#content {
position: relative;
margin-left: auto;
margin-right: auto;
border: 1px solid gray;
min-height: 100px;
width: 800px;
padding: 60px;
}
Run Code Online (Sandbox Code Playgroud)
好吧,尝试在 HTML 中使用段落,而不是重复的 div。它不起作用,因为重复的 div 没有在 CSS 中设置样式。
<div id='content'>
<p>lots of text in here</p>
</div>
Run Code Online (Sandbox Code Playgroud)
如果这解决了您的问题,请随意接受这个答案。