V
V
Vasing2016-04-08 20:59:41
Layout
Vasing, 2016-04-08 20:59:41

flexbox vs float?

I got acquainted with the wonderful flexbox method, until that moment I worked only with floats and now I think that it is possible to get rid of floats, or is it not worth it?
2) Where is flexbox better than float and vice versa?
3) Where not to use flexbox/float?

Answer the question

In order to leave comments, you need to log in

8 answer(s)
Z
zooks, 2016-04-08
@Vasing

Flexbox should always be used .
In the case of old IE, we insert conditional comments with css fixes on old floats under this underbrowser.

<!--[if IE]>
<link href="ie.css" rel="stylesheet">
<![endif]-->

Float is designed to wrap text around a block.

D
dom1n1k, 2016-04-09
@dom1n1k

About the fact that flex is always better - this is of course nonsense. There are many simple situations where it does not give any profit, while the good old float solves the whole problem. Flex, of course, will also decide - but with side effects in the form of incomplete cross-browser compatibility.
At the same time, the proposals to make fallbacks on floats are touching - if you do them anyway, isn’t it easier to limit yourself to them ?!
In the end, the answer to the question is very simple - flex should be used where it provides specific benefits. The most obvious thing is that you need to auto-distribute the width of the blocks with adjustment to the width of the content. Or you need to change the order of the blocks (the order property).
If none of this is planned - flex is not needed! Now we have already spawned grids and "frameworks", where flex is actually used to simulate floats! Well, like stylish, fashionable, youthful. Well, I'm a cool developer, not khukhr-mukhr.
When laying out each block, you need to ask yourself the question: "I use flexbox for what ?" If there is a clear answer to the question - yes, you should use it. If only blah blah like "well, it's modern, progressive, etc." - use the old reinforced concrete techniques.

F
Fedor Ananin, 2016-04-14
@sarathorn

Let's think logically:
1) Flexbox is much more convenient than floats, tables and display:inline-block in 95% of cases
2) Flexbox is supported by all modern browsers, including mobile ones (even IE on Windows Phone 8.1)
3) Many people use alternative browsers , for example, recently I was in a company where computers are ... very old: windows XP, CRT monitors 1024x768 ... But even they use alternative browsers. The example is especially significant because the people in this office have barely mastered the transfer of files by mail.
4) Microsoft has an active policy to upgrade Windows 7, 8, 8.1 to Windows 10, which means that the share of IE is decreasing and the share of Edge is growing, which, minus a couple of minor jambs, renders 1v1 like Chrome.
5) If you continue to support dinosaurs, then people will not be motivated to upgrade their browser / operating system / computer. The most common reason people around me don't want to upgrade to 10 is very simple: on 7/8/8.1 everything works as it should, why change anything? Conclusion: if all site developers at once spit on the support of irrelevant junk, then it will become easier for everyone to live.

R
Rafael™, 2016-04-09
@maxminimus

flexbox is a simple ideal universal formatting tool
with it you can forget about floats and so on junk
but if you have to write in IE - then suffer
but in a couple of years these browsers will die out

M
Mikhail, 2016-04-22
Chirskiy @chirskiy_mixail

Now there are such opportunities that you can use whatever you want, there is a lot of choice, it used to be only tables, and then floats appeared, now use what suits you best, flex is a new technology and in many ways simplifies our lives, but it doesn’t matter about supporting old browsers , there are a bunch of tools, gulp, sass, autoprefixer, all of which make life very easy and support older browsers

R
Roman Ivashkevich, 2016-04-14
@Gobl1n

And most importantly, they just recently described how to work with flexbox without flexbox themselves: Sudo Null IT News

P
Polina Emelyanova, 2016-04-15
@bugo_aneo

To use flex or not to use flex is a matter of using the tool in a SPECIFIC case. I agree, where you don’t know the width and amount of content - flex is like a balm for the wound. BUT THE LACK OF ELEMENTARY KNOWLEDGE ON LAYOUT (what is float and how to use it) FLEX WILL NOT DECIDE! IMHO!
*sorry if anyone is offended.

G
GGatsby, 2017-10-31
@GGatsby

I'm taking a course on front-end, got to flexbox. At first, everything seems confusing, but in the end it turned out to be a very convenient thing in layout

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question