I have 2 divs that I want to centre vertically inside another div. At the moment I have:
Now I understand what is going on here, but I want the left div to be vertically aligned within that container and the right div the same. But they are vertically aligning as a pair and not individually. I have tried various things but can’t seem to get it work.
Live Demo
float: leftfrom#leftand#right.Instead, use
display: inline-block:display: inline-block, you have to deal with the whitespace issue. I chose to remove the whitespace in the HTML between</div>and<div id="right">. See here for what happens if you don’t do that. Removing the whitespace really is the easiest fix, but there are other ways.