html - div-Block 高度取决于里面的内容

标签 html css

各位! 当它内部的表单高度变得更多时,我遇到了更改 block 高度的问题(也许它只是看起来像这样,不知道)。 我在 http://jsfiddle.net/vXNCD 上的 sample

也许我遇到了这个问题,因为我给 form 使用了 position

position: relative;
    left: 13em;
    top: 9em;

如果是这样,如何正确定位? 如何让我的 #content 覆盖所有 inputs

最佳答案

如果你想让你的表单稍微越位,在父元素中使用填充而不是相对位置。

这是 fiddle :http://jsfiddle.net/vXNCD/13/

我所做的是删除相对位置并向#content div 添加填充并添加框大小调整以确保将填充计为宽度的一部分。

#content
{
    width: 70%;
    min-height: 30em;
    background-color: rgba(62,96,111,0.9);
    position: relative;
    margin: 5em auto;

    -webkit-border-radius: 0.42em;
    -moz-border-radius: 0.42em;
    -o-border-radius: 0.42em;
    -ms-border-radius: 0.42em;
    border-radius: 0.42em;

    padding: 9em 13em;    

    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

关于html - div-Block 高度取决于里面的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23173743/

相关文章:

html - Tumblr - 高清图像?

html - iPad 上的 iOS UIWebView 窗口宽度和高度

html - 使用 CSS 对齐图像

html - 从第一个 `li` 本身 CSS 悬停时启动 Mega Sub 菜单

javascript - Bootstrap Modal 中的提交按钮无需输入即可工作

html - 带有堆叠图像的 Bootstrap 列 : need to have same column height

jquery - 将 XML 数据注入(inject) HTML 表

html - 带间距的CSS垂直书写错误

css - 我想在 j2me 中渲染/显示 html 卡片

jquery - 为什么我的easypie号码没有显示在里面?