Html 如何根据内容使div具有自动高度
我似乎找不到我想要的答案。 我想知道如何在不使用float和保持marginauto的情况下自动调整div的高度,从而使div居中 我的问题是Html 如何根据内容使div具有自动高度,html,css,Html,Css,我似乎找不到我想要的答案。 我想知道如何在不使用float和保持marginauto的情况下自动调整div的高度,从而使div居中 我的问题是#contentwrap没有根据#content的高度自动调整高度 随着#content根据内容自动调整高度,我希望#contentwrap也根据#content高度自动调整高度 CSS: HTML: 您只需使用javascript获取视图高度并将该高度设置为您的元素。 通过简单地使用无法完成的CSS。您只需使用javascript获取视图高度并将该高度
#contentwrap
没有根据#content
的高度自动调整高度
随着#content
根据内容自动调整高度,我希望#contentwrap
也根据#content
高度自动调整高度
CSS:
HTML:
您只需使用javascript获取视图高度并将该高度设置为您的元素。
通过简单地使用无法完成的CSS。您只需使用javascript获取视图高度并将该高度设置为您的元素。
只需使用无法完成的CSS即可。只需尝试删除以下内容:
#contentwrap
页边距底部:70px代码>来自#内容
<div id="contentwrapper">
<div id="contentwrap">
<div id="content">
Vice twee irony pickled sriracha mumblecore, VHS beard +1. Shoreditch post-ironic retro, actually plaid roof party irony kogi lo-fi organic. <br />Vice twee irony pickled sriracha mumblecore, VHS beard +1. Shoreditch post-ironic retro, actually plaid roof party irony kogi lo-fi organic.
</div>
</div>
Vice twee讽刺腌制sriracha mumblecore,VHS胡须+1。Shoreditch post反讽复古,实际上格子屋顶派对反讽kogi lo-fi有机
Vice twee irony腌制sriracha mumblecore,VHS胡须+1。Shoreditch post反讽复古,实际上格子屋顶派对反讽kogi lo-fi有机。
#内容包装器{
左边距:131px;
右边距:131px;
}
#内容包装{
保证金:0自动;
位置:相对位置;
宽度:1150px;
边框:1px实心#000;
}
#内容{
保证金:0自动;
位置:相对位置;
边框:1px纯红;
}
只需尝试删除以下内容:
#contentwrap
页边距底部:70px代码>来自#内容
<div id="contentwrapper">
<div id="contentwrap">
<div id="content">
Vice twee irony pickled sriracha mumblecore, VHS beard +1. Shoreditch post-ironic retro, actually plaid roof party irony kogi lo-fi organic. <br />Vice twee irony pickled sriracha mumblecore, VHS beard +1. Shoreditch post-ironic retro, actually plaid roof party irony kogi lo-fi organic.
</div>
</div>
Vice twee讽刺腌制sriracha mumblecore,VHS胡须+1。Shoreditch post反讽复古,实际上格子屋顶派对反讽kogi lo-fi有机
Vice twee irony腌制sriracha mumblecore,VHS胡须+1。Shoreditch post反讽复古,实际上格子屋顶派对反讽kogi lo-fi有机。
#内容包装器{
左边距:131px;
右边距:131px;
}
#内容包装{
保证金:0自动;
位置:相对位置;
宽度:1150px;
边框:1px实心#000;
}
#内容{
保证金:0自动;
位置:相对位置;
边框:1px纯红;
}
#contentwrapper {
margin-left: 131px;
margin-right: 131px;
}
#contentwrap {
margin: 0 auto;
position: relative;
width: 1150px;
display: inline-block;
}
#content {
margin: 0 auto;
margin-bottom: 70px;
position: relative;
}
#contentwrapper {
margin-left: 131px;
margin-right: 131px;
}
#contentwrap {
margin: 0 auto;
position: relative;
width: 1150px;
display: inline-block;
}
#content {
margin: 0 auto;
margin-bottom: 70px;
position: relative;
}
你能举个例子吗。。把你的代码发到一个我在我的手机上有点难做的jsfiddle lol@webkit这个问题很难,而且很简单,从
#contentwrap
和边距底部:70px
从#content
尝试将高度变为0@bindiyapatoliya如果您的问题不清楚,请尝试添加更多解释或图像来解释您的问题。您能举个例子吗。。把你的代码发到一个我在我的手机上有点难做的jsfiddle lol@webkit这个问题很难,而且很简单,从#contentwrap
和边距底部:70px
从#content
尝试将高度变为0@bindiyapatoliya如果您的问题不清楚,请尝试添加更多解释或图片来解释您的问题。
#contentwrapper {
margin-left: 131px;
margin-right: 131px;
}
#contentwrap {
margin: 0 auto;
position: relative;
width: 1150px;
display: inline-block;
}
#content {
margin: 0 auto;
margin-bottom: 70px;
position: relative;
}