Reputation: 241
I can't seem to find the answer I want on SO. I wanted to know how can I auto height a div without using float and maintaining margin auto so the div can be centered.
My problem is that #contentwrap
is not doing auto height according to how tall #content
is.
With #content
having a auto height according to content I want #contentwrap
to also have auto height according to #content
height.
CSS:
#contentwrapper {
margin-left: 131px;
margin-right: 131px;
}
#contentwrap {
margin: 0 auto;
min-height: 700px;
position: relative;
width: 1150px;
}
#content {
margin: 0 auto;
margin-bottom: 70px;
position: relative;
}
HTML:
<div id="contentwrapper">
<div id="contentwrap">
<div id="content">
</div>
</div>
</div>
Upvotes: 1
Views: 112
Reputation: 114
Remove min-height from #contentwrap and add display: inline-block; for #contentwrapper
#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;
}
Upvotes: 1
Reputation: 2764
Simply try to remove this:
min-height
from #contentwrap
margin-bottom: 70px;
from #content
Try this :
<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>
<style>
#contentwrapper {
margin-left: 131px;
margin-right: 131px;
}
#contentwrap {
margin: 0 auto;
position: relative;
width: 1150px;
border:1px solid #000;
}
#content {
margin: 0 auto;
position: relative;
border:1px solid red;
}
</style>
Upvotes: 3
Reputation: 869
You simply use javascript to get the view height and set that height to your element. By simply using CSS that can't be done.
Upvotes: 0