B
B
bro-dev2015-11-12 00:41:15
css
bro-dev, 2015-11-12 00:41:15

Why is clearfix called a hack, a crutch?

Why is clearfix called a hack? Tell me, have you ever used the property clear:both; except for clearfix. I just think it does exactly what it was intended to do.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stalker_RED, 2015-11-12
@Stalker_RED

Yes, we used clear:both. This is a normal css property, nothing special about it.
But clearfix is ​​not just clear:both. The minimum clearfix code also depends on the browser.

S
Sergey, 2015-11-12
Protko @Fesor

clearfix is ​​a pain in the ass, since float elements were not originally intended to be used to build a page layout. But what to do, flexboxes have just appeared.
If you have ever seen the options for wrapping images with text in all sorts of Words, then I think you can catch the essence of this css property.

M
Mikhail, 2015-11-12
Chirskiy @chirskiy_mixail

It seems to me that there was no ::after ::before before, similar things were not supported everywhere like now, and therefore they wrote empty blocks like
Sergey Chikuenok even had such a hack chikuyonok.ru/2009/06/float-columns

.clear {
clear:both;
font-size:0;
overflow:hidden; /* тройной презерватив для IE */
}

Over time, empty divs were replaced with pseudo-elements, correct me if I'm wrong.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question