سؤال

This works, but actually I've never come across it earlier. Does it have some "weak spots"?

div.floated { float: left; }
div.floated+* { clear: both; }

Though I did not notice any "side effect".

هل كانت مفيدة؟

المحلول

You can use it at your will, although according to MDN, you should take into account that universal selector is the most expensive CSS selector in terms of webpage performance.

Universal CSS Selector Performance

نصائح أخرى

Here some problems I see:

  1. "floated" is not a semantic class name.
  2. This will clear adjacent elements after divs with the "floated" class, but not anything that is floated by other means.
  3. In most designs I work with, I don't want to clear adjacent elements. Now I'll have to write more CSS to undo this.

I think I don't understand the value of this.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top