I recently came across this implementation of the OOCSS media object in the inuitcss framework:
.#{$inuit-media-namespace}media,
%#{$inuit-media-namespace}media {
@extend %clearfix;
display: block;
}
.#{$inuit-media-namespace}media__img,
%#{$inuit-media-namespace}media__img {
float: left;
margin-right: $inuit-media-gutter;
> img {
display: block;
}
}
.#{$inuit-media-namespace}media__body,
%#{$inuit-media-namespace}media__body {
overflow: hidden;
display: block;
&,
> :last-child {
margin-bottom: 0;
}
}
While I know what a block formatting context is, I am still not sure why the author used a clearfix on .media
instead of using overflow: hidden;
like in the original media object.
I understood that the block formatting context on the object's body is necessary to prevent the content from flowing below the image, but what benefit has the clearfix on the parent over using the overflow property on it?