标签:put console points 基本 fse span 自动 高度 move
//获取设备的像素比//console.log(window.devicePixelRatio);//控制比例:1/像素比var pixelRatio = 1 / window.devicePixelRatio;//通过js动态设置视口(viewport)document.write(‘<meta name="viewport" content="width=device-width,initial-scale=‘+pixelRatio+‘,minimum-scale=‘+pixelRatio+‘,maximum-scale=‘+pixelRatio+‘" />‘);
// 条件:尺寸越大,则字体大小越大。尺寸越小,则字体大小越小。// 获取html节点var html = document.getElementsByTagName(‘html‘)[0];// 获取屏幕宽度var pageWidth = html.getBoundingClientRect().width;//或者通过document.documentElement.clientWidth获取宽度// 设置html的font-size大小:屏幕宽度 / 固定数值 = 基准值(基准值任何整数都行)html.style.fontSize = pageWidth / 16 + "px";
width: 100%;height: 100%;overflow: hidden;
width: 100%;height: 100%;overflow: auto;
width:100%height:xxrem;position:absolute;top:0;left:0;
-webkit-tap-highlight-color: transparent;text-decoration: none;
-webkit-appearance: none;margin: 0;padding: 0;border: none;
this.style.background = "blue";
var box = document.querySelector(".box");var div = document.querySelector(".div")div.addEventListener( //div中的文字可以被选中
"touchstart",function(e) {
e.stopPropagation();
},false
);
/*事件函数中 默认的第一个 参数 是 event对象*/
"touchmove",function(e) {
e.preventDefault();
}
document.addEventListener(
"touchmove",function(e) {
e.preventDefault();
}
);window.onload = function () {
var div = document.querySelector("#div");/*PC端鼠标事件 在移动端也可以正常使用,但是注意 事件的执行 会有300ms的延迟事件点透:1. 在移动端 PC事件(click,mouse..) 有 300ms的延迟2. 我们点击了页面之后,浏览器会记录点击下去的坐标3. 300ms后,在该坐标找到现在在这的元素 执行事件解决办法:1. 阻止默认事件 (部分安卓机型不支持)2. 不在移动端使用鼠标事件,不用a标签做页面跳转*/div.addEventListener(
"touchend",function (e) {
e.preventDefault();this.style.display = "none";
}
);
};
"touchstart",function(e) {
e.preventDefault();
}
var a = document.querySelectorAll("a");for(var i = 0; i < a.length; i++) {
a[i].addEventListener(
"touchmove",function() {
//在进行touchmove事件的时候设置自定义事件isMove为true
this.isMove = true;
}
);a[i].addEventListener(
"touchend",function() {
//当不在进行touchmove事件的时候
if(!this.isMove) {
window.location.href = this.href;
}this.isMove = false;
}
);
}
"touchmove",function (e){
var touch = e.changedTouches[0];this.innerHTML = touch.pageX +"|"+ touch.pageY;
}
html {
height: 100%;
}body {
margin: 0;height: 100%;position: relative;overflow: hidden;
}#wrap {
position: absolute;left: 0;top: 0;width: 100%;height: 100%;
}#scroll {
position: absolute;left: 0;top: 0;width: 100%;background: #ccc;
}
<div id="scroll">啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br>啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦 <br></div>
标签:put console points 基本 fse span 自动 高度 move
原文地址:http://www.cnblogs.com/hello-web/p/7221430.html