首先需要定义一个文件夹style
style中定义公共样式文件
style——
_minix.scss //这个文件放我们公共的样式方法和处理函数
main.sass //这个是我们每个样式文件中引入的文件,这个文件中@import ‘./mixin’;
//处理样式自适应问题 基于iPhone 6 375px的像素宽度
@function px2rem($x) {
@return $x * 750/ $designWidth / 16 + rem; //sass中使用$
@return @x * 750/ $designWidth / 16 + rem; //less中使用@
}
$designWidth: 750;
// @designWidth: 750;
//没有参数 内容过长现实...
@mixin ellipsis {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
//使用方式
.className{
max-width:100px;
height:30px;
@include ellipsis();
}
//带参数 浮动:默认值是left
@mixin float($float:left) {
float: $float;
// 兼容性判断
@if $lte7 {
display: inline;
}
}
//使用方式
.classNameLeft{
@include float();
}
.classNameRight{
@include float(right);
}
// 带判断 三角形 trian