微信小程序中视频的的控件样式 video controls=“false” 是无效的
解决:
controls="{{false}}"
弹出的浏览器窗口居中显示
function Fun(height,width){window.open ('src', '_blank', 'height='+height+', width='+width+',top='+(screen.height-height)/2+',left='+(screen.width-width)/2+' ,toolbar=no,menubar=no, scrollbars=no, resizable=no,location=n o, status=no'); }
移动端布局 rem
//移动端rem适配 function getRem(pwidth,prem){ var html = document.getElementsByTagName("html")[0]; var oWidth = document.body.clientWidth || document.documentElement.clientWidth; console.log(oWidth); html.style.fontSize = oWidth/pwidth*prem + "px";
} getRem(750,100);//1rem 等于100px
购物车加减效果
<button>+</button> <input type="text" value="1"> <button>-</button> <script> var btn = document.getElementsByTagName('button'); console.log(btn); var Input = document.getElementsByTagName('input')[0]; btn[0].onclick = function() { Input.value = (Input.value++) === 999 ? 999 : Input.value; }; btn[1].onclick = function() { Input.value = (Input.value--) == 0 ? 0 : Input.value; } </script>