html - 当div内的内容增加时,主容器div的高度不会动态增加

标签 html css height

下面是我目前所获得的以及我想要实现的目标的截图。第二张图片我已经能够通过手动增加像素的高度来完成,只是为了说明目的,但我希望这可以根据容器内内容的大小自动实现......

图片 1: enter image description here

图 2: enter image description here

HTML:

<div id="top-body" style="clear:both">
   <div id="info">
    <p>Dixon Woods School of Dance was established 25 years ago in Newbold Verdon. Although lessons still take place in Newbold Verdon the main activities of the school now take place in their purpose built studios in Oadby.
        All lessons are given under the personal supervision of the principal Michelle Dixon-Woods. The school is recognised as having exceptionally high standards, which is reflected in examination and festival results achieved by the pupils.</p>
   </div>
</div>

<div id="footer1">
   <div id="footer-image">
   </div>
</div>

CSS:

top-body {
margin: 0 auto;
background-color: #ffffff;
height: auto;
overflow: hidden;
position: absolute;
top: 197px;
width: 960px;
padding-top: 7px;
}

info {
width: 327px;
float: right;
margin-right: 39px;
margin-top: 14px;
}

#info p {
font-size: 15px;
font-family: "myriad pro";
line-height: 15px;
text-align: justify;
}

#footer1 {
width: 960px;
height: 23px;
}

#footer-image {
width: 100%;
background-image: url('../images/footer-border1.png');
height: 23px;
}

最佳答案

尝试放置div

#info
    {
    clip:auto;
    }

关于html - 当div内的内容增加时,主容器div的高度不会动态增加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16401917/

相关文章:

javascript - 在 React 中滚动到可滚动 div 的底部

javascript - 当 flexbox 宽度改变时改变 flex 元素的顺序

html - 定位、裁剪并向图像、网络添加反射

html - SVG 使用 <embed> : css not picking up styles

ios - 在 uitextview 中获取字符串的结尾

html - Div 未填充 100% 高度

javascript - 为什么当我点击打印按钮时@media print 的选择器没有显示正确的格式?

html - 如何在边框线和菜单项之间添加空间

html - 相同的元素在不同的加载点上具有不同的像素大小

html - Bootstrap 容器或填充高度 100% 浏览器