10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Sass・Compass clearfixの使い分け

Posted at

Sass・Compassでclearfixを使う

Compassにはいろいろなmixinが用意されている
sassを書くとき@import "compass";で最初にcompassをインポートしてやれば使えるようになる

clearfixする

@include clearfix;をつけると自動でoverflow: hidden;をcssとして吐き出してfloatを解除してくれる
通常はこれだけ使うけど、レイアウトによってはoverflow: hidden;してほしくない
そんなときはpie-clearfix

mixinのclearfix

Compass mixinには3つのclerafixが定義されている

  • clearfix
  • legacy-pie-clearfix
  • pie-clearfix

それぞれ出力されるcssはというと
clearfix

css
.hoge {
  overflow: hidden;
  *zoom: 1;
}

legacy-pie-clearfix

css
.clearfix {
  *zoom: 1;
}
.clearfix:after {
  content: "\0020";
  display: block;
  height: 0;
  clear: both;
  overflow: hidden;
  visibility: hidden;
}

pie-clearfix

css
.clearfix {
  *zoom: 1;
}
.clearfix:after {
  content: "";
  display: table;
  clear: both;
}

ということで、ocerflow: hidden; させたくないときはpie-clearfixを使う

10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?