0
0

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.

mixin を include したプロパティ自身を取得するには

0
Last updated at Posted at 2016-10-25
.box {
	&-title {
		...
	}
}

...
// hoge ページ
.hoge {
	.box {
		@include box-base;
	}
}

// fuga ページ
.fuga {
	.box {
		...
	}
}

_box.scss
@mixin box-base {
	$target: unquote("#{&}");

	@if str-index($target, ' ') == null {
	} @else {
		$target: str-slice($target, str-index($root, ' ') + 1, str-length($target));
	}
	
	&-title {
		...
	}
	
	// ここで `.box-title` を取りたい
	@each $category in $categories {
		&.#{$category} {
			#{$target}-title {
				background-image: url(#{$category}_title_bg.gif);
			}
		}
	}
}

とりあえずネストは1つしか考慮してない。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?