In this tutorial i will show how to properly split a
div into 2 columns such that the background of the parent
div is not ignored. Consider the following example. In the example below, the
div is set to blue. The
div inside it. I have tried to split the
div into two columns. As you could see, the split isn’t happening properly. The
background-color of the
div is being ignored by the inner
The reason behind this is the use of
float. When you float those two divs, the content div collapses to zero height. Add the following after the
div but inside the
div. That will force the
div to surround the two internal, floating divs.
Here’s the updated code.
This content has been helpful to you?
Thanks for contributing!