﻿@use "sass:math";
//======================================变量=======================================//

//常用值//
$a:auto; $f:fixed; $j:justify; $h:hidden; $n:none; $v:visible; $s:scroll; $nl:normal; $bh:both; $pd:padding-box; $bb:border-box; $cb:content-box;
//方向//
$b:bottom; $c:center; $l:left; $r:right; $t:top;
//边框样式//
$dt:dotted; $ds:dashed; $sl:solid; $du:double;
//常用数值//
$nb0:0; $nb1:1%; $nb50:50%; $nb100:100%;


//======================================自然属性=======================================//

//层级//
@for $i from 0 through 10 {
	.z-#{$i}{z-index:$i; }
}
//透明度
@for $i from 0 through 10 {
	.op-#{$i}{opacity: math.div($i, 10); }
}
//缩进
@for $i from 0 through 10 {
	.ti-#{$i}{text-indent:$i + em;}
}

//背景百分比定位//
.bgp_50p0  { background-position: $nb50 $nb0; } 		// center top
.bgp_100p0 { background-position: $nb100 $nb0; } 		// right top
.bgp_0p50p { background-position: $nb0 $nb50; } 		// left center
.bgp_0p100p { background-position: $nb0 $nb100; }   	// left bottom
.bgp_50p50p { background-position: $nb50 $nb50; }   	// center center
.bgp_50p100p { background-position: $nb50 $nb100; } 	// center bottom
.bgp_100p50p { background-position: $nb100 $nb50; } 	// right center
.bgp_100p100p { background-position: $nb100 $nb100; } 	// right bottom

//元素可见性//
$vv: (h, $h),(v, $v);
@each $val, $direction in $vv {
	.v-#{$val}{visibility: $direction;}
}

//字体加粗//
$fw:(b:bold, n:$nl, l:lighter, br:bolder);
@each $val, $direction in $fw {
	.fw-#{$val}{font-weight: $direction;}
}

//字体斜体//
$fs:(i:italic, n:$nl);
@each $val, $direction in $fs {
	.fs-#{$val}{font-style: $direction;}
}

//内联定位(上中下)//
$va:(t:$t, m:middle, b:$b, tb:text-bottom, tt:text-top, sp:super, sb:sub);
@each $val, $direction in $va {
	.va-#{$val}{vertical-align: $direction;}
}

//文字排版//
$ta:(c:$c, l:$l, r:$r, j:$j);
@each $val, $direction in $ta {
  .ta-#{$val}{text-align: $direction; }
}

//文字排版最后一行//
$tal:(c:$c, l:$l, r:$r, j:$j);
@each $val, $direction in $tal {
  .tal-#{$val}{text-align-last: $direction; }
}

//字母大小写//
$tt:(n:$n, c:capitalize, u:uppercase, l:lowercase);
@each $val, $direction in $tt {
	.tt-#{$val}{text-transform: $direction;}
}

//字体划线//
$td:(n:$n, o:overline, l:line-through, u:underline);
@each $val, $direction in $td {
	.td-#{$val}{text-decoration: $direction; }
}

//背景铺垫//
$bgr:(n:no-repeat, x:repeat-x, y:repeat-y, r:round, s:space);
@each $val, $direction in $bgr {
	.bgr-#{$val}{background-repeat: $direction; }
}

//背景固定//
$bga:(f:$f);
@each $val, $direction in $bga {
	.bga-#{$val}{background-attachment: $direction; }
}

//背景填充//
$bgs:(cv:cover, ct:contain);
@each $val, $direction in $bgs {
	.bgs-#{$val}{background-size: $direction; }
}

//背景色相对于盒子中显示//
$bgc:(pd:$pd, bb:$bb, cb:$cb);
@each $val, $direction in $bgc {
	.bgc-#{$val}{background-clip: $direction; }
}

//背景图像相对于盒子中定位//
$bgo:(pd:$pd, bb:$bb, cb:$cb);
@each $val, $direction in $bgo {
	.bgo-#{$val}{background-origin: $direction; }
}

//LI样式 实心 空心 小方块 罗马 字母 数字//
$lst:(n:$n, d:disc, c:circle, s:square, u:upper-roman, l:lower-alpha, dc:decimal);
@each $val, $direction in $lst {
	.lst-#{$val}{list-style-type: $direction; }
}

//鼠标指针 手指 文字 更多 十字 求助 箭头//
$cur:(p:pointer, t:text, m:move, c:crosshair, h:help, d:default);
@each $val, $direction in $cur {
	.cur-#{$val}{cursor: $direction; }
}

//清除浮动//
$cl:(n:$n, l:$l, r:$r, b:$bh);
@each $val, $direction in $cl {
	.cl-#{$val}{clear: $direction;}
}

//绘制元素//
$bxz:(bxz-cb:$cb, bxz-bb:$bb);
@each $val, $direction in $bxz {
	.bxz-#{$val}{box-sizing: $direction; }
}

//滚动条//
$ov:(a:$a, v:$v, h:$h, s:$s);
@each $val, $direction in $ov {
	.ov-#{$val}{overflow: $direction; }
}
$ovx:(a:$a, v:$v, h:$h, s:$s);
@each $val, $direction in $ovx {
	.ovx-#{$val}{overflow-x: $direction; }
}
$ovy:(a:$a, v:$v, h:$h, s:$s);
@each $val, $direction in $ovy {
	.ovy-#{$val}{overflow-y: $direction; }
}

//-----------------------------media width-----------------------------//
$w1: 751;
$w2: 992;
$w3: 1200;
$nb: 100;

//================================全局响应式属性=========================//
@mixin media ($grid){
	@content;

	//元素状态//
	$dy:(n:$n, i:inline, b:block, ib:inline-block, f:flex, g:grid, t:table, bc:table-cell);
	@each $val, $direction in $dy {
		.d-#{$grid}-#{$val}{display: $direction;}
	}

	//浮动//
	$fl:(n:$n, l:$l, r:$r);
	@each $val, $direction in $fl {
		.fl-#{$grid}-#{$val}{float: $direction;}
	}

	//定位//
	$pos:(s:static, f:$f, r:relative, a:absolute);
	@each $val, $direction in $pos {
		.pos-#{$grid}-#{$val}{position: $direction;}
	}

	//宽度百分比//
	@for $i from 0 through $nb {.w-#{$grid}-#{$i}p{width: $i*$nb1;}}

	//行高倍数//
	.lh-#{$grid}-0{line-height: 0;}
	@for $i from 10 through $nb {.lh-#{$grid}-#{$i}{line-height: math.div($i, 10);}}

	//box//
	@for $i from 0 through $nb {

	//字体//
	.fz-#{$grid}-#{$i}{font-size: math.div($i, $nb) + rem;}

	//表格间距//
	.bdsp-#{$grid}-#{$i}{border-spacing: math.div($i, $nb) + rem;}

	//内间距//
	.p-#{$grid}-#{$i}{padding:math.div($i, $nb) + rem;}
	.pt-#{$grid}-#{$i}{padding-top:math.div($i, $nb) + rem;}
	.pr-#{$grid}-#{$i}{padding-right:math.div($i, $nb) + rem;}
	.pb-#{$grid}-#{$i}{padding-bottom:math.div($i, $nb) + rem;}
	.pl-#{$grid}-#{$i}{padding-left:math.div($i, $nb) + rem;}

	//外间距//
	.m-#{$grid}-#{$i}{margin:math.div($i, $nb) + rem;}
	.mt-#{$grid}-#{$i}{margin-top:math.div($i, $nb)+ rem;}
	.mr-#{$grid}-#{$i}{margin-right:math.div($i, $nb) + rem;}
	.mb-#{$grid}-#{$i}{margin-bottom:math.div($i, $nb) + rem;}
  .ml-#{$grid}-#{$i}{margin-left:math.div($i, $nb) + rem;}

  //圆角//
  .bdrs-#{$grid}-#{$i}{border-radius:math.div($i, $nb) + rem;}

  }
}

@include media (xs){}
$media-data: (sm, $w1),(md, $w2),(lg, $w3);
@each $grid, $w in $media-data {
	@media only screen and (min-width: $w + px){
		@include media ($grid){}
	}
}

