I have a div element on my page with its height set to 100%. The height of the body is also set to 100%. The inner div has a background and all that and is different from t
Usually this problem arises when the Child elements of a Parent Div are floated. Here is the Latest Solution of the problem:
In your CSS file write the following class called .clearfix along with the pseudo selector :after
.clearfix:after {
content: "";
display: table;
clear: both;
}
Then, in your HTML, add the .clearfix class to your parent Div. For example:
<div class="clearfix">
<div></div>
<div></div>
</div>
It should work always. You can call the class name as .group instead of .clearfix , as it will make the code more semantic. Note that, it is Not necessary to add the dot or even a space in the value of Content between the double quotation "". Also, overflow: auto; might solve the problem but it causes other problems like showing the scroll-bar and is not recommended.
Source: Blog of Lisa Catalano and Chris Coyier
You can also use
display: inline-block;
mine worked with this
Ok, I tried something like this:
body (normal)
#MainDiv {
/* where all the content goes */
display: table;
overflow-y: auto;
}
It's not the exact way to write it, but if you make the main div display as a table, it expands and then I implemented scroll bars.