1.pointer-events: none;
使当前元素的事件失效
2.-webkit-overflow-scrolling: touch;
设置移动设备上横向滑动的惯性效果
3.隐藏横向滑动的滚动条
添加一个小于横滑区域的外层,设置外层的overflow
4.两行截断
-webkit-line-clamp: 2;
display: -webkit-box;
overflow: hidden;
margin-bottom: .05rem;
white-space: normal;
text-overflow: ellipsis;
-webkit-box-orient: vertical;
5.判断页面是否是从缓存里面读取的
$(window).off('pageshow').on('pageshow', function (e) {
if (e.persisted) {
location.reload();
}
});
6.加上跨域带cookie
xhrFields: {withCredentials: true})
7.禁止默写浏览器的左滑返回,右滑前进
在touchstart,touchend阻止事件冒泡即可,即e.stopPropagation();
8.设置渐变
background-image: -webkit-linear-gradient(to top, rgba(0, 0, 0, .4), rgba(0, 0, 0, 0));
background-image: linear-gradient(to top, rgba(0, 0, 0, .4), rgba(0, 0, 0, 0));
9.图片自动左右或者上下裁剪:用于容器固定,图片大小不一的情况
background-size: cover;
10.设置内容居中对齐
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
align-items: center;
-webkit-align-items: center;
box-align: center;
-moz-box-align: center;
-webkit-box-align: center;
-webkit-justify-content: center;
justify-content: center;
-moz-box-pack: center;
-webkit-box-pack: center;
box-pack: center;
11.ue标注和css写出来的颜色可能不一样,可能是浏览器解析不了该颜色,让ue调整颜色
12.根据屏幕放大缩小容器
transform: scale(0.966184);
13.从当前页面跳转到登录页面的时候,可以设置1分钟cookie,来设置用户再次回来以后的连续动作
14.可以通过增加时间抽来清除图片缓存
15.cookie的获取和设置
setCookie(cname, cvalue, exdays) {
let d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
let expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + "; " + expires;
},
getCookie(cname) {
let name = cname + "=";
let ca = document.cookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i].trim();
if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
}
return "";
},