-2

There are some methods to solve the clearfix.
I want to know if any body has some experience about applying clearfix to all elements.
Is there any issue that could cause a notable problem ?

Omid
  • 4,575
  • 9
  • 43
  • 74
  • If you are clearfixing, then nothing will be floating, at which point the clearfixes are not necessary... unless this isn't the reason? Some clarification on why would be helpful – MDEV Dec 24 '12 at 18:42
  • Clearfixes are a horrible practice. If you use them, you should be fired for incompetency. Just sayin. – Shmiddty Dec 24 '12 at 18:46
  • I think I've missed out on something: what's the 'clearfix bug'? – David Thomas Dec 24 '12 at 18:47
  • @SmokeyPHP I'm working on a web app and have to keep all paragraphs cleared. I didn't want to use an extra cleared element. Any way, what you said is a very important issue. – Omid Dec 24 '12 at 18:49
  • @DavidThomas http://stackoverflow.com/questions/8554043/what-actually-is-clearfix – Omid Dec 24 '12 at 18:52
  • @Omid Amraei: That link doesn't say anything about a bug. – BoltClock Dec 24 '12 at 18:53
  • @BoltClock I think he don't want to know anything about a BUG ;) clearfix was the issue. – Omid Dec 24 '12 at 18:56
  • If you want to avoid adding the class of 'clearfix' to all of the elements that require clearfixing, consider a CSS preprocessor. Using a preprocessor allows mixins, so your .less file (or other preprocessor file) would be like this: p { .clearfix; } – Scott Simpson Dec 24 '12 at 18:56
  • 1
    @Omid Amraei: You said yourself in your question that it's a bug. That's why he's asking what this "bug" you're referring to is. – BoltClock Dec 24 '12 at 18:58
  • @ScottSimpson thinking you got something about my problem and what i want to do. But now i think myslef that BoltClock answer is the best. – Omid Dec 24 '12 at 18:59
  • @BoltClock that was just an idiom, don't make me mad friend ;) There is always somebody to ask about nonsignificant word when don't know the answer. ;) – Omid Dec 24 '12 at 19:04
  • FYI, "bug" is a very significant word when it comes to programming. If something is not a bug, *don't go calling it a bug*. Not even idiomatically. – BoltClock Dec 24 '12 at 19:10
  • Ok edited. let me finish it for God's sake. ;) – Omid Dec 24 '12 at 19:15

1 Answers1

3

If you apply clearfix to all elements, then you won't be able to float anything at all because every single element you try to float is going to be cleared immediately.1

If you must use clearfix, you should only use it when absolutely necessary. This means you have to specify which elements you want to apply it to, rather than just giving it to every element.


1 Well, it depends on what kind of clearfix you're using. If you're using the :after pseudo-element, for instance, then it's not going to apply to certain elements in certain browsers. My point still stands, though.

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356