以前总是在各个地方水自己是切图仔,在这次自己接了个外包之后,才知道怎么切图。。。当PSD文件给到我的时候,我是一脸懵逼,怎么搞,以前公司都是切好给我的,,,
1.切图相关
使用ps的切片工具就行了。。。
image.png
在你需要切出的地方,使用切片工具框出来,如果需要透明,那么需要把一些背景隐藏,比如
image.png
然后再切即可
切好后,在菜单栏,文件->存储为web所用格式
image.png
可以用ctrl点中多个切图一起导出
image.png
2.居中定位
需求是将视频在中间位置定死,随页面滚动一直定在中间
position: fixed;
top: 20%;
left: 0;
right: 0;
margin: 0 auto;
3.手机号码正则判断
phone.match(/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/) === null
4.layui表格对接,api数据的格式, 原接口的分页和需要的接口不一致
let thePage = parseInt(page)
if (thePage === 1) {
thePage = thePage - 1
} else {
thePage = thePage + parseInt(limit) - 1
}
5.锚点,锚点切换平缓过渡
$('a').click(function(){
$('html, body').animate({
scrollTop: $( $.attr(this, 'href') ).offset().top
}, 500);
return false;
});
6.windows10连windows服务器报错解决
7.获取访问来源url , document.referrer
需要获取用户从那个地方进入网页的
当然获取关键字也需要,不过搜索引擎把关键字隐掉了
8.获取url的?后面参数, location.search
获取链接问号之后的数据
9.PC端和手机端盘的跳转
在PC端模板页头部引入js
function isMobile() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone",
"SymbianOS", "Windows Phone",
"iPad", "iPod"];
var flag = false;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = true;
break;
}
}
return flag;
}
if(isMobile()) {
location.href = '/m'+location.pathname
}
通过判断userAgent,来决定是使用PC端还是跳转到手机端