css3 移动端页面全屏旋转,横屏显示。
2016-07-18 18:55
706 查看
css3旋转模拟手机横屏。
当手机不能自动旋转时,或有特殊需求。用css3 transform,实现横屏展示。
touch的手势方向没有变,依旧是原来方向,若有相关插件,注意方向。
此处用的jq,可以写成js。
className取镶套的最外层,例如body。
谢谢。
当手机不能自动旋转时,或有特殊需求。用css3 transform,实现横屏展示。
注意:
相关样式注意横屏的显示。touch的手势方向没有变,依旧是原来方向,若有相关插件,注意方向。
此处用的jq,可以写成js。
className取镶套的最外层,例如body。
代码:
/*强制横屏*/ function horizontalScreen(className){ // transform 强制横屏 var conW = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var conH = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; // transform: rotate(90deg); width: 667px; height: 375px;transform-origin:28% 50%; //var iosTopHe = 0;//若有其他样式判断,写于此 $(className).css({ "transform":"rotate(90deg) translate("+((conH-conW)/2)+"px,"+((conH-conW)/2)+"px)", "width":conH+"px", "height":conW+"px", //"margin-top":iosTopHe+"px", // "border-left":iosTopHe+"px solid #000", "transform-origin":"center ce 4000 nter", "-webkit-transform-origin": "center center" }); }
谢谢。
相关文章推荐
- Android 图片压缩
- android studio导入的 No such property: nexusUsername for class
- Android Hook机制之Binder Hook
- Android 插件之Hook机制动态代理
- Android的线程和线程池
- Android Missing Styles. Is the correct theme chosen for this layout?
- iOS开发textField点击背景空白隐藏收起键盘的N种方法
- 微信公众号开发
- Description Resource Path Location Type AndroidManifest.xml file missing!
- Description Resource Path Location Type AndroidManifest.xml file missing!
- Android 监听软件盘关闭的两种方法。
- android 打开热点
- iOS为什么Block的属性声明要用copy
- android 自签名证书生成命令
- Android 高仿 QQ5.0 侧滑菜单效果 自定义控件来袭
- Android 高仿 QQ5.0 侧滑菜单效果 自定义控件来袭
- 弹出按钮----Animator例子
- Android 自定义控件打造史上最简单的侧滑菜单
- app 欢迎界面
- Android 实现形态各异的双向侧滑菜单 自定义控件来袭