May 15, 2023  SEONews

Solving Media Object Float Issues With CSS Block Formatting Contexts — Smashing Magazine


This article covers common problems using CSS floats and how to solve them using a block formatting context (BFC). By understanding the disadvantages of using BFCs and how to minimize them, you can ensure that your content is displayed correctly. Whether you are a beginner or an experienced web developer, you will learn valuable insights and practical solutions for dealing with CSS float issues.

Let’s imagine we’re making a small component. It can be anything, really, but let’s use a media object as an example. Nicole Sullivan had a solid definition of media objects from way back in 2010, and you probably already know the pattern well: some form of media (often an image) on the left and text beside it on the right. The media could be an image or a video, for example.

A media object is a mini layout. The most popular and easy-to-implement layout approaches these days involve CSS Flexbox and Grid. Once upon a time, long ago, some developers might have gone for a table display method instead.

Although it was created to achieve a newspaper or magazine media display on websites, floats were the gold standard for creating layouts before Flexbox and Grid were introduced, even if it wasn’t specifically designed for that use. Again, not the easiest — or the best — way to approach a layout, even for something as small as a media object.

Why are we talking about floats in 2023? Flexbox and Grid are well-suited for the task of a media object, after all. It’s really a matter of...



source: https://news.oneseocompany.com/2023/05/15/solving-media-object-float-issues-with-css-block-formatting-contexts-smashing-magazine_2023051544824.html

Your content is great. However, if any of the content contained herein violates any rights of yours, including those of copyright, please contact us immediately by e-mail at media[@]kissrpr.com.