• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    CSS
  • Created about 8 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

sass mixins

mixins-sass mixins-sass mixins-sass

sass mixins,require Sass ~> 3.3.0

utility

functions

string

list

usage

npm i mixins-sass --save
@import "./node_modules/mixins-sass/src/mixins";

utility

prefix

/**
 * @param $map       css列表
 * @param $vendors   浏览器前缀,默认:webkit moz ms o
 */
@mixin prefix($map, $vendors: webkit moz ms o)

.test {
    @include prefix((transliton: all 0.5s ease-out), webkit);
}

clearfix

@include clearfix;

float

@include float(left);

text-overflow

文字超出显示省略号,支持多行

/**
 * @param $line       超出显示省略号的行数,默认:1
 * @param $substract  为预留区域百分比%,默认:0
 */
@mixin text-overflow($line: 1, $substract: 0);

animation

@include animation(slideUp 900ms ease both) {
    0% {
        transform: translate3d(0, -200px, 0);
    }
    100% {
        transform: translate3d(0, 0, 0);
    }
}

placeholder

// scss
@include placeholder() {
	...
}
// css
::-webkit-input-placeholder {
    ...
}
::-moz-placeholder {
    ...
}
:-ms-input-placeholder {
   ...
}

rem

px转rem

/**
 * @param $property       css属性
 * @param $values         css属性值
 * @param $support-ie     是否对不支持rem的浏览器使用px
 * @param $base           基准字体大小,如果不传会搜索全局变量 $base-font,如果没有默认为 16px
 */
@mixin rem($property, $values, $support-ie: true, $base: null)

@include rem('padding', '10px 5px 5px 10px', true, '16px');

opacity

兼容ie的透明度

arrow

生成上下左右的小箭头:http://lugolabs.com/caret

/**
 * @param $width
 * @param $border-width
 * @param $direction: top bottom left right
 * @param $background-color
 * @param $position 默认relative
 */
@mixin arrow($width, $border-width, $direction, $color, $background-color, $position: relative)

@include arrow(10px, 1px, 'bottom', '#00f', '#fff');

triangle

三角形生成

/**
 * @param $width
 * @param $height
 * @param $color
 * @param $direction: top bottom left right
 */
@mixin triangle($width, $height, $color: #000, $direction: bottom)

/**
 * svg背景图生成三角形
 */
@mixin svg-triangle($width, $height, $color: #000, $direction: bottom)

@include triangle(10px, 5px);

center

居中

/**
 * @param $direction: horizontal vertical both,  default: both
 */
@include center;

media

媒体查询相关

/**
 * @param $min   min-width
 * @param $max   max-width
 */
@mixin screen($min, $max)
@mixin max-screen($width)
@mixin min-screen($width)
@mixin hidpi($ratio: 1.3)

/**
 * @param $filename
 * @param $retina-filename   多个或者一个
 * @param $ratio             多个或者一个
 * @param $background-size
 */
@mixin retina-image($filename, $retina-filename, $ratio: 1.3, $background-size: 100%)
@mixin iphone6($orientation: all)
@mixin iphone6plus($orientation: all)
@mixin iphone5($orientation: all)
@mixin iphone4($orientation: all)
@mixin ipad($orientation: all)
@mixin ipad-mini($orientation: all)
@mixin ipad-retina($orientation: all)

@include retina-image(test.png, test@2.png test@3.png, 2 3);

box-sizing

html {
    @include box-sizing(border-box);
}

touch-scroll

body {
    @include touch-scroll;
}
// css
body {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
}

font

中文字体解决方案,来自https://github.com/zenozeng/fonts.css,有font-heifont-kaifont-songfont-fang-song

body {
    @include font-hei;
}

onepx

移动端1像素方案,通过background-image渐变色实现

/**
 * @param $color
 * @param $direction: top bottom left right vertical all,  default: all
 * @param $pseudo: after before, default: after
 */
.border-l {
    @include onepx(#eee, left);
}

onepx-scale

通过transform实现,支持圆角

/**
 * @param $color
 * @param $direction: top bottom left right vertical all radius,  default: all
 * @param $pseudo: after before, default: after
 * @param $radius default: 1px
 */
.border-r {
    @include onepx-scale(#eee, radius, after, 2px);
}

balloon

气泡提示,来自:balloon.css

/**
 * @param $direction:            top bottom left right
 * @param $bg                    气泡提示背景颜色
 * @param $trangle-width         气泡小三角形宽度
 * @param $trangle-height        气泡小三角形高度
 * @param $color                 气泡文字颜色
 * @param $font                  气泡文字大小
 */
@mixin balloon($direction, $bg, $trangle-width: 18px, $trangle-height: 6px, $color: #fff, $font: 12px)

.balloon {
    @include balloon(top, #000);
}
<span class="balloon" data-balloon="Whats up!">Hover me!</span>

side-line

线中间夹文字效果

http://codepen.io/anon/pen/XjNEAR

/**
 * @param $height  线高  default: 1px
 * @param $space   线距离文字两边的距离 default: 0.5em
 * @param $color   线颜色 default: inherit
 * @param $style   border-style default: solid
 * @param $adjust  线距离底部的距离,默认垂直居中 default: false
 * @param $double  是否需要两条线
 */
@mixin side-line($height: 1px, $space: 0.5em, $color: inherit, $style: solid, $adjust: false, $double: false)

.side-line {
    @include side-line;
}

functions

string

str-split

字符串分隔

@function str-split($string, $delimiter: " ")

str-repeat

字符串重复

@function str-repeat($string, $times)

str-replace

字符串替换

@function str-replace($string, $search, $replace: "")

list

first

返回列表第一项

@function first($list)

last

返回列表最后一项

@function last($list)

prepend

向列表前面插入一个

@function prepend($list, $value)

insert-nth

向列表某个位置插入

@function insert-nth($list, $index, $value)

replace

替换列表的某个元素 $recursive 是否全部替换

@function replace($list, $old-value, $new-value, $recursive: false)

replace-nth

替换列表某个位置的元素

@function replace-nth($list, $index, $value)

remove

删除列表某个元素 $recursive 是否删除所有

@function remove($list, $value, $recursive: false)

remove-nth

删除列表指定位置元素

@function remove-nth($list, $index)

slice

截取列表中的一部分

@function slice($list, $start: 1, $end: length($list))

to-string

列表变成字符串,$glue为连接符,$is-nested是否是嵌套的列表

@function to-string($list, $glue: '', $is-nested: false)

shift

将列表部分元素前置

@function shift($list, $index: 1)

contain

列表是存在某个值

@function contain($list, $value)

More Repositories

1

surge-hosts

hosts for surge,翻墙,强力去APP广告,google,facebook,twitter,youtube,etc
598
star
2

tableExport

tableExport(table导出文件,支持json、csv、txt、xml、word、excel、image、pdf)
JavaScript
295
star
3

wechat-mp-hack

微信公众平台模拟登录自动群发图文消息
TypeScript
121
star
4

JSSDK

微信JS-SDK分析
JavaScript
21
star
5

gulp-devserver

a gulp plugin for static server with livereload,ajax cross domain handler,simulation data generator
JavaScript
15
star
6

blog

个人博客
JavaScript
11
star
7

vscode-GBKtoUTF8

a vscode extension to convert gbk to utf8
TypeScript
10
star
8

TouchSwipe-Zepto-Plugin

TouchSwipe is a zepto plugin to be used with Zepto on touch input devices such as iPad, iPhone etc.Modify from TouchSwipe-Jquery-Plugin
JavaScript
9
star
9

seajs-cache

a seajs plugin to cache js in localstorage
JavaScript
7
star
10

ChromeExtensionDocument

chrome extension中文api文档
HTML
4
star
11

gulp-f2e-structure

gulp前端构建工具
JavaScript
3
star
12

gulp-prepack-js

gulp prepack plugin
JavaScript
3
star
13

jquery.pageScroll

juqery单页滚屏插件
JavaScript
3
star
14

zepto.touch

a zepto/jquery touch plugin
JavaScript
3
star
15

msjt

a cocos2d-html5 game named msjt
JavaScript
3
star
16

angular-lazy-render

angular lazy render page, speed up first screen
JavaScript
3
star
17

gdown

a github repo download tool which support sub dirs or files/github项目下载工具,支持多项目单文件下载以及多级目录下载
JavaScript
3
star
18

express-static-livereload

a express middleware to livereload static files
JavaScript
2
star
19

fe

fe resources collection前端资源搜藏集
2
star
20

browserify-html

Simple HTML transform for Browserify
JavaScript
1
star
21

ads

ad domain collection
JavaScript
1
star
22

domain

domain search
JavaScript
1
star
23

charles-server

koa2 server
JavaScript
1
star
24

api

node.js apis
JavaScript
1
star
25

docs

搜集各种中文文档
1
star
26

flex-layout

cross-platform flex-box layouts http://flex.w3cboy.com/
CSS
1
star
27

diff-match-patch

google diff-match-patch
Python
1
star
28

nativeShare.js

invoke native share method
JavaScript
1
star
29

charles

Fiddler for Chrome Extension
JavaScript
1
star
30

koa-server

node.js koa2 server
JavaScript
1
star
31

huanz.github.com

my own blog
HTML
1
star
32

wechat

wechat api
JavaScript
1
star
33

eatMoonCakes

A html5 game based on createJS for The Mid Autumn Festival
JavaScript
1
star
34

vscode-projects

a vscode extension to quick manage your projects
TypeScript
1
star