常用样式集合
斑马纹表格
1 | <table class="sl-table-inside is-zebras"></table> |
1 | .sl-table-inside * { |
按钮效果
hover亮片
1
<button class="flash-btn">click me</button>
1
2
3
4
5
6
7
8
9
10
11
12
13
14.flash-btn:before{
content:'';
background:rgba(255,255,255,.5);
position:absolute;
height:100%;
width:2em;
left:-4em;
top:0;
transform:skewX(-45deg) translateX(0);
}
.flash-btn:hover:before{
transition:all .7s ease-in-out;
transform:skewX(-45deg) translateX(10em);
}click水纹
1
<button class="ripple-btn">click me</button>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22.ripple-btn{
overflow: hidden;
user-select: none;
}
.ripple{
position: absolute;
background-color: rgba(0, 0, 0, .15);
border-radius: 100%;
transform: scale(0);
pointer-events: none;
}
.ripple.show{
animation-name: ripple;
animation-duration: .75s;
animation-timing-function: ease-out;
}
@keyframes ripple{
to{
transform: scale(2);
opacity: 0;
}
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21var addRippleEffect = function(e) {
var target = e.target;
if(target.tagName.toLowerCase() !== "button") return false;
var rect = target.getBoundingClientRect();
var ripple = target.querySelector(".ripple");
if(!ripple){//水纹是否已存在
ripple = document.createElement("span");
ripple.className = 'ripple';
ripple.style.height = ripple.style.width = Math.max(rect.width, rect.height) + 'px';
target.appendChild(ripple)
}
ripple.classList.remove("show");
var top = e.pageY - rect.top - ripple.offsetHeight / 2 - document.body.scrollTop;
var left = e.pageX - rect.left - ripple.offsetWidth /2 - document.body.scrollLeft;
ripple.style.top = top + 'px';
ripple.style.left = left + 'px';
ripple.classList.add("show")
return false
}
//点击时给按钮添加水纹效果
document.addEventListener("click", addRippleEffect, false);
详细:jsfiddle地址
背景颜色渐变
1 | <div class="linear-color">linear color change</div> |
1 | .linear-color{ |
详细:jsfiddle地址
随光标移动的下划线
1 | <ul class="moving-line"> |
1 | .moving-line{ |
详细:jsfiddle地址
表格内容垂直居中
1 | <div class="sl-table"> |
1 | .sl-table{ |
详细:jsfiddle地址
单个内容垂直居中
1 | .vertical-middle{ |
表单左右两边拓展
1 | <!-- 带icon输入类型 --> |
1 | .form-item{ |
详细:jsfiddle地址
上传excel文件类型
1 | <input type="file" name="file" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"> |
选中
1 | ::selection{ |
重绘scroll
1 | /* type 1 */ |
重绘radio
1 | <div class="label-radio"> |
1 | .label-radio{ |
详细:jsfiddle地址
重绘checkbox
1 | <label class="label-checkbox" for="land"> |
1 | .label-checkbox{ |
详细:jsfiddle地址
自定义圆or球
1 | <div class="sl-circle"></div> |
1 | .sl-circle{ |
详细:jsfiddle地址
confirm对话框
1 | <!-- first type: --> |
1 | .layer-mask{ |
详细:jsfiddle地址
图片模糊效果
1 | <div class="bg-filter"> |
1 | .bg-filter{ |
详细:jsfiddle地址
时间线
1 | <div class="time-line"> |
1 | .time-line{ |
详细:jsfiddle地址
input自动补全背景色
1 | input:-webkit-autofill, |
placeholder color
1 | input::-webkit-input-placeholder, |
禁止字体放大缩小-iOS
1 | .font{ |
走马灯-IE
1 | <marquee behavior="alternate" direction="left"> |
扫描二维码,分享此文章