1、 单行文字溢出时省略号
.test{
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
}
2、 多行文字溢出时省略号
.test{
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
}
3、 移动端单条0.5px细线
.border-b{
position: relative;
}
.border-b:after{ // 这里只写了底部
position: absolute;
content: '';
display: block;
height: 1px;
top: auto;
right: auto;
bottom: 0;
left: 0;
100%;
background-color: #dddddd;
z-index: 2;
-webkit-transform-origin: 0 100%;
transform-origin: 0 100%;
pointer-events: none;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
}
4、移动端四周0.5px细线
.border-all{
position: relative;
border:none;
}
.border-all:before{
position: absolute;
content: '';
top: 0px;
left: 0px;
200%;
height: 200%;
border: 1px solid #dbdbdb;
border-radius: 2px; // 圆角大小要写两倍
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
-webkit-transform: scale(0.5, 0.5);
transform: scale(0.5, 0.5);
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
5、 ios元素内滚动惯性及边缘弹动
.test{
-webkit-overflow-scrolling: touch;
}
6、遮罩镂空效果
.test{
box-shadow: 0 0 0 9999px ;
border-radius: 50%; // 可设置圆角
}
或
.test{
outline: 9999px solid rgba(0,0,0,.75); // 不能设置圆角,但能适配不支持css3的IE
}
DEMO:
> 大神张鑫旭根据此原理实现了[操作向导镂空提示jQuery插件](http://www.zhangxinxu.com/wordpress/2017/05/jquery-guide-js-plugin/) ### 7、用css画三角形 ```` .test { height: 0; 0; border-top: 10px solid transparent; border-bottom: 10px solid transparent; border-right: 10px solid #f5f5f5; } ```` DEMO: