$.fn.screenCheck = function() {
var pDiv = $('<div></div>');
pDiv.addClass("screenCheck");
pDiv.attr("id","screen")
pDiv.css({
"display": "none",
"width": "100%",
"height": "100%",
"position": "absolute",
"left": 0,
"top": 0,
"z-index": "1000",
"background": "rgba(0,0,0,0.9)", })
var svg = '<svg class="svg" width="100" height="100" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g class="transform-group"><g transform="scale(0.03125, 0.03125)"><path d="M864.4 67.2 541.9 67.2c-52.8 0-95.6 43.1-95.6 96.2l0 697.3c0 53.1 42.8 96.2 95.6 96.2l322.6 0c52.8 0 95.6-43.1 95.6-96.2L960.1 163.4C960 110.3 917.2 67.2 864.4 67.2zM625.5 151.4l155.3 0 0 36.1L625.5 187.5 625.5 151.4zM569.5 151.8c10.3 0 18.6 8.4 18.6 18.7 0 10.3-8.3 18.7-18.6 18.7s-18.6-8.4-18.6-18.7C550.9 160.2 559.2 151.8 569.5 151.8zM712 886.3c-17.9 0-32.4-14.6-32.4-32.6 0-18 14.5-32.6 32.4-32.6 17.9 0 32.4 14.6 32.4 32.6C744.4 871.7 729.9 886.3 712 886.3zM900.3 800.5 506 800.5l0-577 394.3 0L900.3 800.5zM207.3 588.3l-59.7 0 0 180.3 59.7 0L207.3 588.3zM183.5 744.6l-12 0L171.5 612.3l12 0L183.5 744.6zM407.9 528l0-24L247.2 504l0 364.7 160.7 0 0-24L271 844.7 271 528 407.9 528zM178.6 854c16.8 0 30.5-13.8 30.5-30.7 0-16.9-13.7-30.7-30.5-30.7-16.8 0-30.5 13.8-30.5 30.7C148.1 840.2 161.8 854 178.6 854zM178.6 816.6c3.7 0 6.7 3 6.7 6.7 0 3.7-3 6.7-6.7 6.7-3.7 0-6.7-3-6.7-6.7C171.9 819.6 174.9 816.6 178.6 816.6zM64 524l0 324.6c0 59.6 48.2 108.2 107.5 108.2l236.4 0 0-24L171.5 932.8c-46.1 0-83.7-37.8-83.7-84.2L87.8 524c0-46.4 37.5-84.2 83.7-84.2l236.4 0 0-24L171.5 415.8C112.2 415.9 64 464.4 64 524zM274 155.6c3.3-0.4 6.6-0.7 9.9-1L241 203.6l17.9 15.9 71.2-81.2-89.5-61.9-13.5 19.8 50.7 35c-2.3 0.2-4.5 0.4-6.8 0.7-95.1 12.4-168.1 84.9-186.4 174.5l22.9 7C123 232.4 188.5 166.8 274 155.6z" fill="#ecf0f1"></path></g></g></svg><p>请将屏幕调正</p>'; var cDiv = $("<div></div>")
cDiv.css({
"width": "150px",
"height": "150px",
"position": "absolute",
"left": 0,
"right": 0,
"top": 0,
"bottom": 0,
"color": "#fff",
"margin": "auto",
"text-align":"center",
"font-size": "20px"
}) cDiv.html(svg); cDiv.appendTo(pDiv);
this.append(pDiv);
var updateOrientation = function(){
if(window.orientation=='-90' || window.orientation=='90'){
$('#screen').show()
}else{
$('#screen').hide()
}
};
window.onorientationchange = updateOrientation;
}

依赖Jquery,使用方式

$(function(){
$('body').screenCheck();
})

正好今天有提这个需求,所以用jq插件封装了一个手机横竖屏提醒的方法,图片采用的是SVG,所以直接用就可以。

效果如下:

        

H5 手机横竖屏判读的更多相关文章

  1. JS判断手机横竖屏

    在移动端开发时,有时候需要判断手机的横竖屏,那么就需要用到window.orientation这个参数,通过这个参数可以判断出手机是处在横屏还是竖屏状态. 屏幕方向对应的window.orientat ...

  2. js 判断手机横竖屏的实现方法(不依赖任何其他库)

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  3. zepto判断手机横竖屏

    var CheckOrientation = (function(){ var win = $( window ), get_orientation, last_orientation, initia ...

  4. js和css实现手机横竖屏预览思路整理

    实现效果,如上图. 首先,实现手机页面在PC端预览, 则先在网上找到一个手机的背景图片,算好大概内间距,用来放预览的页面,我这里是给手机预览页面的尺寸按iphone5的尺寸来的: 一个手机页面在这里预 ...

  5. CSS3(@media)判断手机横竖屏

    @media all and (orientation : landscape) { h2{color:red;}/*横屏时字体红色*/ } @media all and (orientation : ...

  6. javascript判断iphone/android手机横竖屏模式的函数

    function orientationChange(){ switch(window.orientation) { case 0: // Portrait case 180: // Upside-d ...

  7. iphone手机不同版本兼容、横竖屏

    /* 兼容问题*/ @media screen and (device-width: 320px) and (device-height: 480px) and (-webkit-device-pix ...

  8. Android零基础入门第76节:Activity数据保存和横竖屏切换

    在前面几期学习了Activity的创建.配置.启动和停止,还学了Activity的生命周期,本期一起来学习Activity有关的更多事儿. 一.数据保存 通过上一期 LogCat 窗口打印的日志可以看 ...

  9. [Flex] flex手机项目如何限制横竖屏?只允许横屏?

    flex手机项目如何限制横竖屏?只允许横屏?   有人知道吗?求教.. 工程中 xxx-app.xml 找到</aspectRatio> 去掉注释 修改为<aspectRatio&g ...

随机推荐

  1. 【Luogu】P3971Alice And Bob(贪心)

    题目链接 容易发现值为x的点只可能从值为x-1的点转移过来,所以我们把原序列连成一棵树,dfs序就是原序列的一种形式. 就可以直接求啦 #include<cstdio> #include& ...

  2. 【Luogu】P3159交换棋子(超出我能力范围的费用流)

    题目链接 明显超出我能力范围. 只放题解. 再放代码. #include<cstring> #include<algorithm> #include<cstdio> ...

  3. 算法复习——扫描线(hdu1542)

    题目: Problem Description There are several ancient Greek texts that contain descriptions of the fable ...

  4. Miracast HDCP 等知识

    Miracast 通讯架构中关于视频数据处理流程的部分.整个视频数据处理及传输的流程,大致上分为几个阶段,一开始将撷取到系统的画面及声音进行压缩,而压缩后的影音数据再转为基本封包串流(Packetiz ...

  5. 5whys分析法在美团工程师中的实践

    转载美团博客:https://tech.meituan.com/5whys-method.html 前言 网站的质量和稳定性对于用户和公司来说至关重要,但是在网站的快速发展过程中,由于各种原因导致事故 ...

  6. iis 配置 aspnet起始页

    起始页配置:在default document上面加上路径就可以了,例如 /home/kickoffjob asp.net 关于起始页的一般设置: 1: 在web.config中,加入form认证: ...

  7. 从网上搜集的X86 显示 int 10H

    INT 10H 是由 BIOS 对屏幕及显示器所提供的服务程序,而后倚天公司针对倚天中文提供了许多服务程序,这些服务程序也加挂在 INT 10H 内.使用 INT 10H 中断服务程序时,先指定 AH ...

  8. 安卓WebView在项目中总结

    一.简介 在安卓开发中我们会遇到许多处理网页的功能,以下就是我在实际中用到的分享给大家 1.显示和渲染Web页面 2.可和JavaScript交互调用 二.常用的方法 //激活WebView为活跃状态 ...

  9. Codeforces 629 A. Far Relative’s Birthday Cake

      A. Far Relative’s Birthday Cake   time limit per test 1 second memory limit per test 256 megabytes ...

  10. 利用github搭建个人网站

    1.注册一个github  https://github.com/ 2.新建一个仓库  仓库名 用 Owner.github.io 的格式,然后点击创建 3.源码上传至github 安装github桌 ...