@mixin position ($value:0 0,$coord:top left,$pos:absolute) {
position: $pos;
$length: length($value);
@if $length == 1 {
#{nth($coord,1)}: $value;
}
@else if $length == 2 {
#{nth($coord,1)}: nth($value,1);
#{nth($coord,2)}: nth($value,2);
}
}
/*指定なし*/
.a {
@include position;
}
.a {
position: absolute;
top: 0;
left: 0;
}
/*位置の値を1つ指定*/
.b { @include position(10px); }
.b {
position: absolute;
top: 10px;
}
/*指定の位置1箇所を指定*/
.c { @include position(10px, right); }
.c {
position: absolute;
right: 10px;
}
/*位置の値を2つ指定*/
.d { @include position(10px 5px); }
.d {
position: absolute;
top: 10px;
left: 5px;
}
/*指定の位置2箇所を指定*/
.e { @include position(10px 5px, bottom right); }
.e {
position: absolute;
bottom: 10px;
right: 5px;
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
01