Advertisement
matthillco

A "clearfix" mixin for LESS

Jun 19th, 2012
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 0.76 KB | None | 0 0
  1. /*
  2.     A LESS mixin for clearing any element within your CSS.
  3.     This means you can avoid any extra classes in your HTML.
  4.     However, this *WILL* bloat your compiled CSS files if you
  5.     use it on a lot of elements, so use with caution.
  6.  
  7.     Note that you can still add a "clearfix" class to HTML
  8.     elements if you wish: the LESS compiles to a usable CSS
  9.     class too.
  10.  
  11.     Matt Hill, 2012-06-19
  12. */
  13.  
  14. /* LESS */
  15. .clearfix {
  16.     &:before,&:after {
  17.         content:""; display:table;
  18.     }
  19.     &:after {
  20.         clear:both;
  21.     }
  22.     zoom:1 /* For old IE, does nothing in other browsers */
  23. }
  24.  
  25. /* HOW TO USE */
  26.  
  27. h1 {
  28.     font-size:4em;
  29.     .clearfix;
  30. }
  31.  
  32. /* COMPILED CSS OUTPUT */
  33.  
  34. h1 {
  35.     font-size:4em;
  36.     zoom:1
  37. }
  38. h1:before,h1:after {
  39.         content:""; display:table;
  40. }
  41. h1:after {
  42.     clear:both
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement