It is because overflow: hidden
, among other properties, introduces a new block formatting context.
You can read about the effects in this great article:
The magic of overflow: hidden
UPDATE: I’ve rewritten your jsFiddle into something that is working (tested on Chrome). Instead of defining margin-left
on the #red
and #blue
(which would act differently due to overflow: hidden
), I’ve put a margin-right
on #yellow
.