Skip to content

Instantly share code, notes, and snippets.

@ysakmrkm
Last active December 10, 2015 20:58
Show Gist options
  • Save ysakmrkm/4491971 to your computer and use it in GitHub Desktop.
Save ysakmrkm/4491971 to your computer and use it in GitHub Desktop.
SassのPlaceholderで、親参照セレクタ(&)の前にセレクタを記述すると、意図しない展開が行われる。
%clearfix {
	&:before ,
	&:after {
		content:"";
		display:table;
	}

	&:after {
		clear:both;
	}

	* html & {
		zoom:1;
	}

	*+html & {
		zoom:1;
	}
}

#hoge ul {
	@extend %clearfix;
}

が、

#hoge ul:before ,
#hoge ul:after {
	content:"";
	display:table;
}

#hoge ul:after {
	clear:both;
}

* html #hoge ul ,
#hoge * html ul {//不必要
	zoom:1;
}

* + html #hoge ul ,
#hoge * + html ul {//不必要
	zoom:1;
}

になる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment