常用的sass编译库
- @charset "UTF-8";
- /*引进图片合并给一个变量(后面会用到这个变量)*/
- $sprites:sprite-map("pwd/*.png",$spacing:8px,$layout: vertical);
- /*转换px到rem*/
- $browser-default-font-size : 20px !default;
- @function pxTorem($px){
- @if $px == {$px:0px}
- @return $px / $browser-default-font-size * 1rem;
- }
- @function pxTo2rem($px){
- @if $px == {$px:0px}
- @return $px / ($browser-default-font-size*) * 1rem;
- }
- /*雪碧图mixin引块,pc和移动端因为目前编译不过GIF,故暂用png8*/
- $media:ture;
- @mixin iconItem($sprites,$name,$iE6:null){
- background-image:sprite-url($sprites); //获取整个雪碧图路径
- background-repeat:no-repeat;
- @if $iE6 != null{ //null
- _background-image:sprite-url($iE6); //此处传进来的格式须是png8
- }
- $width:image-width(sprite-file($sprites,$name)); //sprite-file 获取目标图片
- $height:image-height(sprite-file($sprites,$name)); //获取目标图片
- $toalWidth:image-width(sprite-path($sprites)); //获取整张图的宽度
- $totalHeight:image-height(sprite-path($sprites)); //获取整张图的高度
- $widthHalf:ceil($width/); //获取宽度的一半
- $heightHalf:ceil($height/); //获取高度的一半
- //sprite-position 获取目标图的位置,nth操作数组
- $posX:round(nth(sprite-position($sprites,$name),)); //获取沿x轴的位移
- $posY:round(nth(sprite-position($sprites, $name), )); //获取沿y轴的位移
- @if $media{//wap
- height:pxTorem($heightHalf);
- width:pxTorem($widthHalf);
- background-position: pxTo2rem($posX) pxTo2rem($posY);
- background-size:pxTo2rem($toalWidth) pxTo2rem($totalHeight);
- } @else{//PC
- height:$height;
- width:$width;
- background-position:sprite-position($sprites,$name);
- }
- }
- /*带时间戳的图片,pc和移动端 ,$imgUrl必须带文件夹和文件名字符串,例"icon/pig.png"*/
- @mixin timestampImg($imgUrl){
- background-image:image-url($imgUrl);
- background-repeat:no-repeat;
- $width:image-width($imgUrl);
- $height:image-height($imgUrl);
- @if $media{ //wap
- width:pxTo2rem($width);
- height:pxTo2rem($height);
- background-size:pxTo2rem($width) pxTo2rem($height);
- } @else{
- height:$height;
- width:$width;
- }
- }
- /*base64位的图片,pc和移动端 ,$imgUrl必须带文件夹和文件名字符串,例"icon/pig.png"*/
- @mixin base64Img($imgUrl){ //这里一定要分开写background 不然会引起background-size 与background合并引起手机端无法显示
- background-image:inline-image($imgUrl);
- background-repeat:no-repeat;
- $width:image-width($imgUrl);
- $height:image-height($imgUrl);
- @if $media{ //wap
- width:pxTo2rem($width);
- height:pxTo2rem($height);
- background-size:pxTo2rem($width) pxTo2rem($height);
- } @else{
- height:$height;
- width:$width;
- }
- }
- //圆角
- @mixin boradius($size){
- -webkit-border-radius:$size;
- -moz-border-radius:$size;
- -o-border-radius:$size;
- -ms-border-radius:$size;
- border-radius:$size;
- }
- %box{
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- }
- %inlineb{display:inline-block;}
- %block{display:block;}
- //绝对居中
- @mixin pscenter($width,$height){
- width:$width;
- height:$height;
- position:absolute;
- left:%;
- top:%;
- margin:(-$height/) (-$width/)
- }
- // 文字隐藏
- %text_indent {
- font-size: ;
- color: rgba(,,,);
- text-indent: -9999em;
- overflow: hidden;
- }
- // 文字自动换行
- %text_break {
- word-break: break-all;
- }
- // 文字省略:单行
- %text_oneline {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- // 文字省略:两行
- %text_twoline {
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: ;
- -webkit-box-orient: vertical;
- }
- // 文字省略:自定义多行
- @mixin elli($elli) {
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: $elli;
- -webkit-box-orient: vertical;
- }
- // flex 布局
- %box {
- display: box;
- display: -ms-box;
- display: -webkit-box;
- display: flex;
- display: -ms-flexbox;
- display: -webkit-flex;
- }
- %flex {
- display: block;
- flex: ;
- -ms-flex: ;
- -webkit-flex: ;
- box-flex: ;
- -ms-box-flex: ;
- -webkit-box-flex: ;
- }
- // 清除表单样式
- %input_clear {
- border: none;
- background: none;
- -webkit-appearance: none;
- -webkit-border-radius: ;
- }
- // 固定定位条
- %fixedBar {
- position: fixed;
- left: ;
- right: ;
- width: %;
- }
- /* ************************全局模块样式************************** */
- * {
- -webkit-tap-highlight-color: transparent;
- outline: ;
- }
- body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td {
- margin: ;
- padding: ;
- vertical-align: baseline;
- }
- img {
- border: none;
- vertical-align: top;
- }
- a img{border: none}
- i, em {
- font-style: normal;
- }
- ol, ul {
- list-style: none;
- }
- input, select, button,textarea, h1, h2, h3, h4, h5, h6 {
- font-size: %;
- font-family: inherit;
- }
- table {
- border-collapse: collapse;
- border-spacing: ;
- }
- a, a:visited {
- text-decoration: none;
- color: #;
- }
- a:focus{
- outline:;
- }
- html,body{font-size:$browser-default-font-size;height:%; }
- body {
- margin: auto;
- min-width: 320px;
- max-width: 640px;
- background: #fff;
- // font-size: 14px;
- font-family: Helvetica,STHeiti STXihei, Microsoft JhengHei, Microsoft YaHei, Arial;
- line-height: 1.5;
- color: #;
- -webkit-text-size-adjust: % !important;
- -webkit-user-select: none;
- user-select: none;
- }
- .g_cf:after{
- display:block;
- content:'\20';
- clear:both;
- height:;
- visibility:hidden;
- }
- input{-webkit-appearance: none;}
- .g_cf{
- *zoom:;
- overflow:hidden
- }
- .g_h10{height:pxTo2rem(10px);}
- .g_h20{height:pxTo2rem(20px);}
- .g_h30{height:pxTo2rem(30px);}
- .g_h35{height:pxTo2rem(35px)}
- .g_h100{height:pxTo2rem(100px)}
扩展:
@content:在sass3.2.0中引入, 可以用来解决css3中 @meidia 或者 @keyframes 带来的问题。它可以使@mixin接受一整块样式,接收的样式从@content开始
- //sass 样式
- @mixin max-screen($res){
- @media only screen and ( max-width: $res )
- {
- @content;
- }
- }
- @include max-screen(480px) {
- body { color: red }
- }
- //css 编译后样式
- @media only screen and (max-width: 480px) {
- body { color: red }
- }
使用@content解决@keyframes关键帧的浏览器前缀问题
- // 初始化变量
- $browser: null;
- // 设置关键帧
- @mixin keyframes($name) {
- @-webkit-keyframes #{$name} {
- $browser: '-webkit-'; @content;
- }
- @-moz-keyframes #{$name} {
- $browser: '-moz-'; @content;
- }
- @-o-keyframes #{$name} {
- $browser: '-o-'; @content;
- }
- @keyframes #{$name} {
- $browser: ''; @content;
- }
- }
- // 引入
- @include keyframes(scale) {
- % {
- #{$browser}transform: scale(0.8);
- }
- }
- // css编译后
- @-webkit-keyframes scale {
- -webkit-transform: scale(0.8);
- }
- @-moz-keyframes scale {
- -moz-transform: scale(0.8);
- }
- @-o-keyframes scale {
- -o-transform: scale(0.8);
- }
- @keyframes scale {
- transform: scale(0.8);
- }
我的常用sass工具库(移动端):
- @charset "UTF-8";
- /*引进图片合并给一个变量(后面会用到这个变量)*/
- $sprites:sprite-map("qqvip/*.png",$spacing:8px,$layout: vertical);
- /*转换px到rem*/
- $browser-default-font-size : 20px !default;
- @function pxTorem($px){
- @if $px == {$px:0px}
- @return $px / $browser-default-font-size * 1rem;
- }
- @function pxTo2rem($px){
- @if $px == {$px:0px}
- @return $px / ($browser-default-font-size*) * 1rem;
- }
- // 初始化变量
- $browser: null;
- // 设置关键帧
- @mixin keyframes($name) {
- @-webkit-keyframes #{$name} {
- $browser: '-webkit-'; @content;
- }
- @-moz-keyframes #{$name} {
- $browser: '-moz-'; @content;
- }
- @-o-keyframes #{$name} {
- $browser: '-o-'; @content;
- }
- @keyframes #{$name} {
- $browser: ''; @content;
- }
- }
- /*雪碧图mixin引块,pc和移动端因为目前编译不过GIF,故暂用png8*/
- $media:ture;
- @mixin iconItem($sprites,$name,$iE6:null){
- background:sprite-url($sprites) no-repeat; //获取整个雪碧图路径
- @if $iE6 != null{ //null
- _background:sprite-url($iE6) no-repeat; //此处传进来的格式须是png8
- }
- $width:image-width(sprite-file($sprites,$name)); //sprite-file 获取目标图片
- $height:image-height(sprite-file($sprites,$name)); //获取目标图片
- $toalWidth:image-width(sprite-path($sprites)); //获取整张图的宽度
- $totalHeight:image-height(sprite-path($sprites)); //获取整张图的高度
- $widthHalf:ceil($width/); //获取宽度的一半
- $heightHalf:ceil($height/); //获取高度的一半
- //sprite-position 获取目标图的位置,nth操作数组
- $posX:round(nth(sprite-position($sprites,$name),)); //获取沿x轴的位移
- $posY:round(nth(sprite-position($sprites, $name), )); //获取沿y轴的位移
- @if $media{//wap
- height:pxTorem($heightHalf);
- width:pxTorem($widthHalf);
- background-position: pxTo2rem($posX) pxTo2rem($posY);
- background-size:pxTo2rem($toalWidth) pxTo2rem($totalHeight);
- } @else{//PC
- height:$height;
- width:$width;
- background-position:sprite-position($sprites,$name);
- }
- }
- /*带时间戳的图片,pc和移动端 ,$imgUrl必须带文件夹和文件名字符串,例"icon/pig.png"*/
- @mixin timestampImg($imgUrl){
- background:image-url($imgUrl) no-repeat;
- $width:image-width($imgUrl);
- $height:image-height($imgUrl);
- @if $media{ //wap
- width:pxTo2rem($width);
- height:pxTo2rem($height);
- background-size:pxTo2rem($width) pxTo2rem($height);
- } @else{
- height:$height;
- width:$width;
- }
- }
- /*base64位的图片,pc和移动端 ,$imgUrl必须带文件夹和文件名字符串,例"icon/pig.png"*/
- @mixin base64Img($imgUrl){
- background-image:inline-image($imgUrl);
- background-repeat:no-repeat;
- $width:image-width($imgUrl);
- $height:image-height($imgUrl);
- @if $media{ //wap
- width:pxTo2rem($width);
- height:pxTo2rem($height);
- background-size:pxTo2rem($width) pxTo2rem($height);
- } @else{
- height:$height;
- width:$width;
- }
- }
- //圆角
- @mixin boradius($size){
- -webkit-border-radius:$size;
- -moz-border-radius:$size;
- -o-border-radius:$size;
- -ms-border-radius:$size;
- border-radius:$size;
- }
- %box{
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- }
- %inlineb{display:inline-block;}
- %block{display:block;}
- //绝对居中
- @mixin pscenter($width,$height){
- width:$width;
- height:$height;
- position:absolute;
- left:%;
- top:%;
- margin:(-$height/) (-$width/)
- }
- // 文字省略:单行
- %text_oneline {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- // 文字省略:两行
- %text_twoline {
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: ;
- -webkit-box-orient: vertical;
- }
- // 文字省略:自定义多行
- @mixin elli($elli) {
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: $elli;
- -webkit-box-orient: vertical;
- }
- // flex 布局
- %boxflex {
- display: box;
- display: -ms-box;
- display: -webkit-box;
- display: flex;
- display: -ms-flexbox;
- display: -webkit-flex;
- }
- %flex {
- display: block;
- flex: ;
- -ms-flex: ;
- -webkit-flex: ;
- box-flex: ;
- -ms-box-flex: ;
- -webkit-box-flex: ;
- }
- // 清除表单样式
- %input_clear {
- border: none;
- background: none;
- -webkit-appearance: none;
- -webkit-border-radius: ;
- }
- // 固定定位条
- %fixedBar {
- position: fixed;
- left: ;
- right: ;
- width: %;
- }
- /* ************************全局模块样式************************** */
- * {
- -webkit-tap-highlight-color: transparent;
- outline: ;
- }
- body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td {
- margin: ;
- padding: ;
- vertical-align: baseline;
- }
- body{background:#EAEAEA}
- img {
- border: none;
- vertical-align: top;
- }
- a img{border: none}
- i, em {
- font-style: normal;
- }
- ol, ul {
- list-style: none;
- }
- input, select, button,textarea, h1, h2, h3, h4, h5, h6 {
- font-size: %;
- font-family: inherit;
- }
- table {
- border-collapse: collapse;
- border-spacing: ;
- }
- a, a:visited {
- text-decoration: none;
- color: #;
- }
- a:focus{
- outline:;
- }
- html,body{font-size:$browser-default-font-size;height:%; }
- body {
- margin: auto;
- min-width: 320px;
- max-width: 640px;
- background: #eaeef2;
- // font-size: 14px;
- font-family: Helvetica,STHeiti STXihei, Microsoft JhengHei, Microsoft YaHei, Arial;
- line-height: 1.5;
- color: #;
- -webkit-text-size-adjust: % !important;
- -webkit-user-select: none;
- user-select: none;
- }
- .g_cf:after{
- display:block;
- content:'\20';
- clear:both;
- height:;
- visibility:hidden;
- }
- input{-webkit-appearance: none;}
- .g_cf{
- *zoom:;
- *overflow:hidden
- }
- .hide{display:none};
- .display{display:block};
- .g_h5{height:pxTo2rem(5px);}
- .g_h10{height:pxTo2rem(10px);}
- .g_h10{height:pxTo2rem(10px);}
- .g_h15{height:pxTo2rem(15px);}
- .g_h20{height:pxTo2rem(20px);}
- .g_h25{height:pxTo2rem(25px);}
- .g_h30{height:pxTo2rem(30px);}
- .g_h35{height:pxTo2rem(35px)}
- .g_h40{height:pxTo2rem(40px);}
- .g_h50{height:pxTo2rem(50px)}
- .g_h70{height:pxTo2rem(70px)}
- .g_h100{height:pxTo2rem(100px)}
- .g_h130{height:pxTo2rem(130px)}
- .fs2_6{color:#;font-size: pxTo2rem(20px)}
- .fs25_6{color:#;font-size: pxTo2rem(25px)}
- .fs2_9{color:#;font-size: pxTo2rem(20px)}
我的常用sass库,不用rem,用px em库:
- @charset "UTF-8";
- @import 'mod_border';
- /*引进图片合并给一个变量(后面会用到这个变量)*/
- $sprites:sprite-map("icon/*.png",$spacing:8px,$layout: vertical);
- /*转换px到rem*/
- $browser-default-font-size : 16px !default;
- /***640下2倍px 转换为 1倍px**/
- @function pxTo($px){
- @if $px == {$px:0px}
- @return $px / ;
- }
- /***转换为em**/
- @function pxToem($px){
- @if $px == {$px:0px}
- @return $px / $browser-default-font-size * 1em;
- }
- @function pxTo2em($px){
- @if $px == {$px:0px}
- @return $px / ($browser-default-font-size*) * 1em;
- }
- // 初始化变量
- $browser: null;
- // 设置关键帧
- @mixin keyframes($name) {
- @-webkit-keyframes #{$name} {
- $browser: '-webkit-'; @content;
- }
- @-moz-keyframes #{$name} {
- $browser: '-moz-'; @content;
- }
- @-o-keyframes #{$name} {
- $browser: '-o-'; @content;
- }
- @keyframes #{$name} {
- $browser: ''; @content;
- }
- }
- /*雪碧图mixin引块,pc和移动端因为目前编译不过GIF,故暂用png8*/
- $media:ture;
- @mixin iconItem($sprites,$name,$iE6:null){
- background:sprite-url($sprites) no-repeat; //获取整个雪碧图路径
- @if $iE6 != null{ //null
- _background:sprite-url($iE6) no-repeat; //此处传进来的格式须是png8
- }
- $width:image-width(sprite-file($sprites,$name)); //sprite-file 获取目标图片
- $height:image-height(sprite-file($sprites,$name)); //获取目标图片
- $toalWidth:image-width(sprite-path($sprites)); //获取整张图的宽度
- $totalHeight:image-height(sprite-path($sprites)); //获取整张图的高度
- $widthHalf:ceil($width/); //获取宽度的一半
- $heightHalf:ceil($height/); //获取高度的一半
- //sprite-position 获取目标图的位置,nth操作数组
- $posX:round(nth(sprite-position($sprites,$name),)); //获取沿x轴的位移
- $posY:round(nth(sprite-position($sprites, $name), )); //获取沿y轴的位移
- @if $media{//wap
- height:$heightHalf;
- width:$widthHalf;
- background-position: $posX/ $posY/;
- background-size:$toalWidth/ $totalHeight/;
- } @else{//PC
- height:$height;
- width:$width;
- background-position:sprite-position($sprites,$name);
- }
- }
- /*带时间戳的图片,pc和移动端 ,$imgUrl必须带文件夹和文件名字符串,例"icon/pig.png"*/
- @mixin timestampImg($imgUrl){
- background:image-url($imgUrl) no-repeat;
- $width:image-width($imgUrl);
- $height:image-height($imgUrl);
- @if $media{ //wap
- width:$width/;
- height:$height/;
- background-size:$width/ $height/;
- } @else{
- height:$height;
- width:$width;
- }
- }
- /*base64位的图片,pc和移动端 ,$imgUrl必须带文件夹和文件名字符串,例"icon/pig.png"*/
- @mixin base64Img($imgUrl){
- background-image:inline-image($imgUrl);
- background-repeat:no-repeat;
- $width:image-width($imgUrl);
- $height:image-height($imgUrl);
- @if $media{ //wap
- width:$width/;
- height:$height/;
- background-size:$width/ $height/;
- } @else{
- height:$height;
- width:$width;
- }
- }
- @mixin size($width, $height:false){
- @if not $height {
- $height : $width;
- }
- width: $width + px;
- height: $height + px ;
- }
- //圆角
- @mixin boradius($size){
- -webkit-border-radius:$size;
- -moz-border-radius:$size;
- -o-border-radius:$size;
- -ms-border-radius:$size;
- border-radius:$size;
- }
- @mixin border-radius($size){
- -webkit-border-radius:$size;
- -moz-border-radius:$size;
- -o-border-radius:$size;
- -ms-border-radius:$size;
- border-radius:$size;
- }
- %boxSize{
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- }
- %inlineb{display:inline-block;}
- %block{display:block;}
- //绝对居中
- @mixin pscenter($width,$height){
- width:$width;
- height:$height;
- position:absolute;
- left:%;
- top:%;
- margin:(-$height/) (-$width/)
- }
- // 文字省略:单行
- %text_oneline {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- // 文字省略:两行
- %text_twoline {
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: ;
- -webkit-box-orient: vertical;
- }
- // 文字省略:自定义多行
- @mixin elli($elli) {
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: $elli;
- -webkit-box-orient: vertical;
- }
- // flex 布局
- %box{
- display: box;
- display: -ms-box;
- display: -webkit-box;
- display: flex;
- display: -ms-flexbox;
- display: -webkit-flex;
- }
- %boxflex {
- display: box;
- display: -ms-box;
- display: -webkit-box;
- display: flex;
- display: -ms-flexbox;
- display: -webkit-flex;
- }
- %flex {
- display: block;
- flex: ;
- -ms-flex: ;
- -webkit-flex: ;
- box-flex: ;
- -ms-box-flex: ;
- -webkit-box-flex: ;
- }
- // 清除表单样式
- %input_clear {
- border: none;
- background: none;
- -webkit-appearance: none;
- -webkit-border-radius: ;
- }
- // 固定定位条
- %fixedBar {
- position: fixed;
- left: ;
- right: ;
- width: %;
- }
- @mixin center($width, $height){
- width: $width + px;
- height: $height + px ;
- position: absolute;
- left: %;
- top: %;
- margin-left: $width / (-) + px;
- margin-top: $height / (-) + px;
- }
- /* ************************全局模块样式************************** */
- * {
- -webkit-tap-highlight-color: transparent;
- outline: ;
- }
- body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td {
- margin: ;
- padding: ;
- vertical-align: baseline;
- }
- body{background:#EAEAEA}
- img {
- border: none;
- vertical-align: top;
- }
- a img{border: none}
- i, em {
- font-style: normal;
- }
- ol, ul {
- list-style: none;
- }
- input, select, button,textarea, h1, h2, h3, h4, h5, h6 {
- font-size: %;
- font-family: inherit;
- }
- table {
- border-collapse: collapse;
- border-spacing: ;
- }
- a, a:visited {
- text-decoration: none;
- color: #;
- }
- a:focus{
- outline:;
- }
- html,body{font-size:$browser-default-font-size;height:%; }
- body {
- margin: auto;
- min-width: 320px;
- max-width: 640px;
- background: #fff;
- // font-size: 14px;
- font-family: Helvetica,STHeiti STXihei, Microsoft JhengHei, Microsoft YaHei, Arial;
- line-height: 1.5;
- color: #;
- -webkit-text-size-adjust: % !important;
- -webkit-user-select: none;
- user-select: none;
- }
- .g_cf:after{
- display:block;
- content:'\20';
- clear:both;
- height:;
- visibility:hidden;
- }
- input{-webkit-appearance: none;}
- .g_cf{
- *zoom:;
- *overflow:hidden
- }
- .hide{display:none};
- .display{display:block};pxTo2em
- .g_h5{height:pxTo2em(5px);}
- .g_h10{height:pxTo2em(10px);}
- .g_h10{height:pxTo2em(10px);}
- .g_h15{height:pxTo2em(15px);}
- .g_h20{height:pxTo2em(20px);}
- .g_h25{height:pxTo2em(25px);}
- .g_h30{height:pxTo2em(30px);}
- .g_h35{height:pxTo2em(35px)}
- .g_h40{height:pxTo2em(40px);}
- .g_h50{height:pxTo2em(50px)}
- .g_h70{height:pxTo2em(70px)}
- .g_h100{height:pxTo2em(100px)}
- .g_h130{height:pxTo2em(130px)}
- .fs2_6{color:#;font-size: pxTo2rem(20px)}
- .fs25_6{color:#;font-size: pxTo2rem(25px)}
- .fs2_9{color:#;font-size: pxTo2rem(20px)}
- .cl_666{color:# !important;}
- .red{color:red !important}
- .bd_top_no{border-top:none !important}
我的常用sass工具库(pc端):
- @charset "utf-8";
- /*引进图片合并给一个变量(后面会用到这个变量)*/
- $sprites1:sprite-map("cloud/*.png",$spacing:10px,$layout: vertical);
- /*转换px到rem*/
- $browser-default-font-size : 20px !default;
- @function pxTorem($px){
- @if $px == {$px:0px}
- @return $px / $browser-default-font-size * 1rem;
- }
- @function pxTo2rem($px){
- @if $px == {$px:0px}
- @return $px / ($browser-default-font-size*) * 1rem;
- }
- /*雪碧图mixin引块,pc和移动端因为目前编译不过GIF,故暂用png8*/
- $media:false;
- @mixin iconItem($sprites,$name,$iE6:null){
- background:sprite-url($sprites) no-repeat; //获取整个雪碧图路径
- @if $iE6 != null{ //null
- _background:sprite-url($iE6) no-repeat; //此处传进来的格式须是png8
- }
- $width:image-width(sprite-file($sprites,$name)); //sprite-file 获取目标图片
- $height:image-height(sprite-file($sprites,$name)); //获取目标图片
- $toalWidth:image-width(sprite-path($sprites)); //获取整张图的宽度
- $totalHeight:image-height(sprite-path($sprites)); //获取整张图的高度
- $widthHalf:ceil($width/); //获取宽度的一半
- $heightHalf:ceil($height/); //获取高度的一半
- //sprite-position 获取目标图的位置,nth操作数组
- $posX:round(nth(sprite-position($sprites,$name),)); //获取沿x轴的位移
- $posY:round(nth(sprite-position($sprites, $name), )); //获取沿y轴的位移
- @if $media{//wap
- height:pxTorem($heightHalf);
- width:pxTorem($widthHalf);
- font:$posX;
- font:$posY;
- background-position: pxTo2rem($posX) pxTo2rem($posY);
- background-size:pxTo2rem($toalWidth) pxTo2rem($totalHeight);
- } @else{//PC
- height:$height;
- width:$width;
- background-position:sprite-position($sprites,$name);
- }
- }
- /*带时间戳的图片,pc和移动端 ,$imgUrl必须带文件夹和文件名字符串,例"icon/pig.png"*/
- @mixin timestampImg($imgUrl){
- background:image-url($imgUrl) no-repeat;
- $width:image-width($imgUrl);
- $height:image-height($imgUrl);
- @if $media{ //wap
- width:pxTo2rem($width);
- height:pxTo2rem($height);
- background-size:pxTo2rem($width) pxTo2rem($height);
- } @else{
- height:$height;
- width:$width;
- }
- }
- /*base64位的图片,pc和移动端 ,$imgUrl必须带文件夹和文件名字符串,例"icon/pig.png"*/
- @mixin base64Img($imgUrl){
- background:inline-image($imgUrl) no-repeat;
- $width:image-width($imgUrl);
- $height:image-height($imgUrl);
- @if $media{ //wap
- width:pxTo2rem($width);
- height:pxTo2rem($height);
- background-size:pxTo2rem($width) pxTo2rem($height);
- } @else{
- height:$height;
- width:$width;
- }
- }
- @mixin boradius($size){
- -webkit-border-radius:$size;
- -moz-border-radius:$size;
- -o-border-radius:$size;
- -ms-border-radius:$size;
- border-radius:$size;
- }
- %box{
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- }
- %inlineb{display:inline-block;}
- %block{display:block;}
- //绝对居中
- @mixin pscenter($width,$height){
- width:$width;
- height:$height;
- position:absolute;
- left:%;
- top:%;
- margin:(-$height/) (-$width/)
- }
- /*******************基础样式*******************/
- /*\5FAE\8F6F\96C5\9ED1 微软雅黑 '\5b8b\4f53'宋体*/
- html,body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, textarea, p, blockquote, th, td, hr, button, article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
- padding: ;
- margin:
- }
- html,body{font:12px/1.5 '\5FAE\8F6F\96C5\9ED1','\5b8b\4f53',sans-serif,arial;}
- img {
- border: none;
- }
- ul, ol {
- list-style: none
- }
- input, textarea, select, button {
- resize: none;
- font-family: inherit;
- font-size: inherit;
- font-weight: inherit;
- outline: none;
- font:12px/1.5 '\5FAE\8F6F\96C5\9ED1','\5b8b\4f53',sans-serif,arial;
- }
- button, input[type="button"], input[type=submit], input[type=reset] {
- cursor:pointer;
- border: none;
- }
- input[type="text"]{
- color:#ccc
- }
- select{color:#}
- input[type="search"] {
- -webkit-appearance:textfield
- }
- /* ie6 ie7去除text产生的蓝色边框 */
- input[type=submit], input[type=reset] {
- filter:chroma(color=#);
- }
- //关闭ie10里面的叉
- input:-ms-clear{display:none;}
- a img {
- bord: none;
- }
- a{
- outline:none;
- text-decoration:none;
- -webkit-tap-highlight-color:rgba(,,,);
- blr:expression(this.onFocus=this.blur());
- }
- a:focus{
- outline:;
- }
- .g_cf:after{
- display:block;
- content:'\20';
- clear:both;
- height:;
- visibility:hidden;
- }
- .g_cf{
- *zoom:;
- overflow:hidden
- }
- .g_h5{height:5px}
- .g_h10{height:10px}
- .g_h15{height:15px}
- .g_h20{height:20px}
- .g_h30{height:30px}
- .g_h40{height:40px}
- .g_h100{height:100px}
常用的sass编译库的更多相关文章
- sass编译
sass编译 命令行编译 单文件转换命令 sass style.scss style.css 单文件监听命令 sass --watch style.scss:style.css 文件夹监听命令 sas ...
- 怎么使用Less/Sass编译工具koala
怎么使用Less/Sass编译工具koala 如何使用Less/Sass编译工具koala 一.SASS调试插件的方法 如需调试功能,请在编译输出的时候输出debug信息,那样解析的css文件中就会包 ...
- sass安装:webpack sass编译失败,node-sass安装失败的终极解决方
文章来源:sass安装:webpack sass编译失败,node-sass安装失败的终极解决方 sass难言之隐-sass安装的坑 之前花了很多时间折腾node-sass,发现sass老是安装不上 ...
- Sublime插件支持Sass编译和Babel解析ES6 & .sublime-build文件初探
用Sublime Text蛮久了,配置配来配去的,每次换电脑都得重头再配过,奈何人老了脑子不中用了,得好好整理一些,下次换电脑就有得参考了.. 同事说,他的WebStorm简直太方便,自身集成了很多方 ...
- Sass学习之路(3)——Sass编译
Sass的编译也是在我们使用Sass的时候必须要经过的一个步骤,因为".sass"和".scss"文件并不能直接使用<link>标签引用,最终其实还 ...
- ruby环境sass编译中文出现Syntax error: Invalid GBK character错误解决方法
sass文件编译时候使用ruby环境,无论是界面化的koala工具还是命令行模式的都无法通过,真是令人烦恼. 容易出现中文注释时候无法编译通过,或者出现乱码,找了几天的解决方法终于解决了. 这个问题的 ...
- Sass 编译的几种方法
常常有人会问,使用 Sass 进行开发,那么是不是直接通过“<link>”引用“.scss”或“.sass”文件呢? 那么这里告诉大家,在项目中还是引用“.css”文件,Sass 只不过是 ...
- sass 工具库
github : https://github.com/uustoboy/base_mixins ( 有坑慎用 ) 项目截图: _base_mixins.scss 混合宏的引入文件; _setting ...
- .Net 常用插件及第三方库
.Net 常用插件及第三方库 一:第三方插件 1:基于响应式编程思想的oc 地址:https://github.com/ReactiveCocoa/ReactiveCocoa 2:hud提示框 地址: ...
随机推荐
- css鼠标移动到文字上怎样变化背景颜色
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 使用特殊构造的5GB文件测试Win2012Dedup功能
WinServer2012一个崭新的功能就是支持重复数据删除功能.为了测试这个功能的情况,特别构造了一个特殊的5GB文件用于此次测试.惯例,先说下测试环境的搭建1 使用ESXi5上的版本8的VM,安装 ...
- 图片后门捆绑利用工具 – FakeImageExploiter
在这里,要向大家推荐一款名为“Fake Image Exploiter”的安全工具,该工具可以在图片文件中捆绑隐藏的恶意.bat或.exe程序,方便钓鱼或社工攻击测试过程中的入侵控制.如果受害者点击该 ...
- iOS 图片切片的简单实现
图片切片就是将一张图片按一定比例切分,中间部分系统自动填充空白, 这样在文本多行输入的时候,将具有特定形状的图片作为背景, 即使文本行数很多,也不会使图片走形. //即使你按5/5分,还是3/7分系统 ...
- 数据结构 http://www.cnblogs.com/sun-haiyu/p/7704654.html
数据结构与算法--从平衡二叉树(AVL)到红黑树 上节学习了二叉查找树.算法的性能取决于树的形状,而树的形状取决于插入键的顺序.在最好的情况下,n个结点的树是完全平衡的,如下图“最好情况”所示,此时树 ...
- make的自动变量和预定义变量
make的自动变量 $@ 规则目标的文件名.如果目标是档案文件的一个成员,"$@"就是档案文件的名称 $% 当目标是档案文件的一个成员时,"$%"是该成员的名称 ...
- Unity3d实现幸运转盘
完成效果 我说一下制作流程,然后再看后面的代码1.创建一个image,选择我们的转盘背景图,素材找我或者网上都有,不多说了哈:2.创建一个空物体,位于转盘的正中心,因为我们的转盘指针的旋转中心是根据空 ...
- sql替换数据库字段中的字符
UPDATE `table_name` SET `field_name` = replace (`field_name`,'from_str','to_str') WHERE ……说明:table_n ...
- Ubuntu16.04下Mongodb(离线安装方式|非apt-get)安装部署步骤(图文详解)(博主推荐)
不多说,直接上干货! 说在前面的话 首先,查看下你的操作系统的版本. root@zhouls-virtual-machine:~# cat /etc/issue Ubuntu LTS \n \l r ...
- /etc/hosts
/etc/hosts 是 Linux 系统中一个负责IP地址与域名快速解析的文件,解析优先级:DNS缓存 > hosts > DNS服务(/etc/resolv.conf) 文件格式:网络 ...