html5自动横屏的方法

摘要:
html5自动横屏的方法varevt="onorientationchange"inwindow?"orientationchange":"resize";window.addEventListener(evt,function(){console.log(evt);varwidth=document.documentElement.clientWidth;varheight=docum

html5自动横屏的方法
<pre>
var evt = "onorientationchange" in window ? "orientationchange" : "resize";
window.addEventListener(evt, function() {
console.log(evt);
var width = document.documentElement.clientWidth;
var height = document.documentElement.clientHeight;
$print = $('#print');
if( width > height ){
$print.width(width);
$print.height(height);
$print.css('top', 0 );
$print.css('left', 0 );
$print.css('transform' , 'none');
$print.css('transform-origin' , '50% 50%');
}
else{
$print.width(height);
$print.height(width);
$print.css('top', (height-width)/2 );
$print.css('left', 0-(height-width)/2 );
$print.css('transform' , 'rotate(90deg)');
$print.css('transform-origin' , '50% 50%');
}
</pre>

免责声明:文章转载自《html5自动横屏的方法》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇docker容器中启动uwsgi秒退xcode 修改类名 变量名下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

linux中export的作用

 https://blog.csdn.net/damontive/article/details/50352722 参考:http://www.cnblogs.com/zhangze/articles/1832542.html以前一直觉得export可有可无,虽然知道export是干嘛的,不就是把本地变量变成全局变量么(实际中叫环境变量),但是感觉好像没有...

要过年啦,用canvas做了个烟火效果

  声明:本文为原创文章,如需转载,请注明来源WAxes,谢谢!   要过年了,过年想到的就是放烟火啦。。。。于是就用canvas写了个放烟火的效果,鼠标点击也会产生烟火,不过不要产生太多烟火哦,一个烟火散出的粒子是30到200个之间,当页面上的粒子数量达到一定的时候,页面就会很卡咯,我也没特意去优化神马的。以后有空再说吧。   直接上DEMO吧:放烟火 ...

bigNumber.js的简单使用

sum 计算传入的参数和,参数类型可以是 String,Number // 两数之和 var x = BigNumber.sum('11', 23) x.toNumber() // 34 // 多个参数 arr = [2, new BigNumber(14), '15.9999', 12] var y = BigNumber.sum(...arr) y.t...

js传递数据一些方式

1.用Image对象的src属性 var img = new Image(); img.src = "http://www.xxx.con/?data1=1"; 创建Image对象,通过其src属性可以向xxx地址传递数据,后台php可以通过GET方法获取src属性中“?”以后的数据。 2.script标签的src属性 var sc = document....

h5中的input keyup触发事件在ios中需点击键盘换行才执行

var bname = 'input'; if (navigator.userAgent.indexOf("MSIE") != -1) { bname = 'propertychange'; } if(navigator.userAgent.match(/android/i) == "and...

Unity3D ZFBrowser (EmbeddedBrowser) 插件嵌入网页无法输入中文问题

  网页嵌入插件最好的应该就是ZFBrowser了, 可是使用起来也是问题多多, 现在最要命的是网页输入不能打中文, 作者也没打算接入IME, 只能自己想办法了...   搞了半天只想到一个办法, 就是通过Unity的IME去触发中文输入, 然后传入网页, 也就是说做一个透明的 InputField 盖住网页的输入文本框, 然后在 Update 或是 on...