The end of the clearfix hack?
rachelandrew.co.uk
rachelandrew.co.uk
Why is the unhacked behaviour desirable? If I put a thing in a thing, surely I want it to stay in the thing?!
Here's a demo: http://codepen.io/anon/pen/ggGgWb
Here's the "clearfixed" version which is nonsensical: http://codepen.io/anon/pen/xgXgry
That floats were press-ganged into layout does not mean their basic behaviour is bad, it just means they were used for something that was never intended (due to a lack of actual layout tools in CSS until CSS3) and they were not very good at it.
And note that the lack of layout tools was not limited to "applicative" layouts, most papers are laid out in multiple text columns yet that fairly simple and common layout was not supported either until CSS3.
You cannot have a div that is both `display: inline-block` and `display: flow-root` at the same time, for example.
That's really not true[0], "display: flex", "display: grid" or "display: table" are all inner display properties, which is why inline-flex, inline-grid or inline-table exist ("display: flex" sets the outer display mode to "block" and the inner one to "flex", "display: inline-flex" sets the outer display mode to "inline" and the inner one to "flex").
Which is why CSS3 split display properties between outer display (block, inline or run-in) and inner display (flow, flow-root, table, flex, grid or ruby), which can be specified independently e.g. `display: inline flow-root`.
Furthermore `display: inline-block flow-root` makes no sense
1. `inline-block` is specifically a "legacy" display property which impacts both inner and outer display (and thus is not compatible with a separate inner display property)
2. `inline-block` already means `inline flow-root` so `display: inline-block flow-root` would expand to `display: inline flow-root flow-root`
[0] and has not been since CSS2 and display: table, possibly CSS1's display: list-item
Furthermore there are values which have more complex interactions/natures than just inner/outer e.g. "contents" (which removes the element's box but leaves the descendants — including pseudo-elements), "list-item" (which can be combined with any outer type but only the flow or flow-root inner types, and generates an internal pseudo-element), or the "internal values" which only make sense within wider display context (table and ruby).
[1]: https://lists.w3.org/Archives/Public/www-style/2014Sep/0399....
About the only reason I can think of off the top of my head is that you / your team already fully grok floats, they are sufficiently powerful for your use case, and you don't want to invest the time to learn flexbox to achieve the same outcome as you could already achieve.
Our support schedule is at https://www.gov.uk/service-manual/technology/designing-for-d...
The linked article uses an image floated left, with text wrapping around it. Curious to know how you'd [sanely] accomplish the same result in flexbox?
Floats aren't just for structural layout. Even with 100% browser support for Flexbox, I'll still be floating some things.
In fact floats aren't for structural layout at all, they were used for it because there were no structural layout tools available at the time.
.container {
display: table;
width: 100%;
}
See bottom example here http://codepen.io/jrf0110/pen/xgXPGjI've never had to use the clearfix hack (that's probably a lie, but I can't recall a time in my career where I didn't just use the display: table; width: 100%; method)
It looks like the difference may be some legacy IE6 thing.
In ancient times some browsers required setting a width or height as well.
For example, consider a feature like arrow function support in JavaScript: http://caniuse.com/#feat=arrow-functions Click "usage relative" to scale by the relative popularity of different browser versions.
Despite only being standardised and implemented in browsers last year, arrow functions are already supported in the large majority of deployed web clients, including Edge, Firefox, Chrome and Safari, both desktop and mobile.
Nowadays, new features, particularly relatively small and uncontroversial ones like display: flex-root, can get implemented across browsers very quickly.
It still is largely true unfortunately.
IE10/11 are at about ~4% global usage. Less than Opera Mini. And a large number of those users will have access to another browser. We've found many enterprises keep IE around to access legacy services, but let people install Chrome in order to access things that need a modern browser.
The days when it was worth supporting IE for new development work has long since passed. Company policies that mandate doing so should be challenged as a waste of time and money.
it doesn't mean anything for a business. for all you know 50% of users visiting a specific website could still be using IE10/11. global numbers were always irrelevant.
[1] http://www.census.gov/newsroom/releases/archives/facts_for_f...
That said, you are responding to my incredulity, and I take disabilities sufficiently at least sufficiently seriously that a blind person presents every year at the conference we have been running for our ecosystem and we get tons of praise for our support of their issues.
In some cases, I will even argue that supporting old browsers is related to accessibility: if you are making a product such as a communications tool, one where many if not most users don't directly pay you for their use as you make money from a subset of users, people on older browsers are often people with older computers, who have lower income and less ability to arbitrarily plunk down money to upgrade their technology.
Just as we legally mandate people consider the needs of the disabled, I personally think we might be in need of some regulation that demands we also consider the needs of the poor and disconnected: there are tons of users (by which I mean "entire percentage points, by number competitive with blind people as a group of users but with less sympathy from the public") using older versions of browsers because they were stranded by Apple on an older iPod or iPhone with an out-of-date version of MobileSafari, or who would have to pay for a new version of Windows to even be able to use Chrome, or whose only access to a computer is a shared facility where the computers run something they have no control over. When we build websites that don't let them use our service, we essentially are building an implicit class hierarchy.
Global usage is not the number that matters for businesses though - it's userbase percentage, and unfortunately that number for IE is quite higher than I'd like (over 10%).
Nowadays I don't use floats anymore. Flexbox is the current layout recommendation and I encourage you not to create legacy CSS stylesheet layouts with float.
'Some people, when confronted with a layout problem, think "I know, I'll use floats." Now they have two problems.'
Not until all browswers support it.
If making a polyfill is the solution, we risk ending up with a bigger polyfill file than the actual CSS implementation in the browser. If that is the case we can better do styling with JS.
I've had difficulties implementing similar things in the past.
(Obviously: starting from date supporting old browsers costs more than supporting them brings in, which depends on your product and your customers)