媒体查询iphone6、iphone6 plus,js判断设备型号

/* 兼容问题*/
@media screen and (device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2){
.dialog-agreement-con{
height: 45%;/* iphone4*/
}
}
@media screen and (device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2){
.dialog-agreement-con{
height: 55%;/* iphone5*/
}
}
@media only screen and (min-device-width: 375px) and (max-device-width: 667px) and (orientation : portrait) {
.dialog-agreement-con{
height: 60%;/* iphone6竖屏*/
}
}
@media only screen and (min-device-width: 414px) and (max-device-width: 736px) and (orientation : portrait) {
.dialog-agreement-con{
height: 60%;/* iphone6 plus竖屏*/
}
}
.dialog-agreement-con{
overflow-y:scroll;
margin-bottom: 2rem;
}

CSS判断横屏竖屏
@media screen and (orientation: portrait) {
/*竖屏 css*/
}
@media screen and (orientation: landscape) {
/*横屏 css*/
}

JS判断横屏竖屏
//判断手机横竖屏状态:
window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function() {
if (window.orientation === 180 || window.orientation === 0) {
alert(‘竖屏状态!‘);
}
if (window.orientation === 90 || window.orientation === -90 ){
alert(‘横屏状态!‘);
}
}, false);
//移动端的浏览器一般都支持window.orientation这个参数,通过这个参数可以判断出手机是处在横屏还是竖屏状态。

// 横屏监听
var updateOrientation = function(){
if(window.orientation==‘-90‘ || window.orientation==‘90‘){
$(‘.landscape-wrap‘).removeClass(‘hide‘);
console.log(‘为了更好的体验,请将手机/平板竖过来!‘);
}else{
$(‘.landscape-wrap‘).addClass(‘hide‘);
console.log(‘竖屏状态‘);
}
};
window.onorientationchange = updateOrientation;

时间: 2024-08-11 03:27:17

媒体查询iphone6、iphone6 plus,js判断设备型号的相关文章

css样式,媒体查询,垂直居中,js对象

下面是一些截图,有关查询效率,css样式,媒体查询,垂直居中,js基本类型.  

JS判断设备终端(PC,iPad,iPhone,android,winPhone)和浏览器

var ua = navigator.userAgent; var browser = {}, weixin = ua.match(/MicroMessenger\/([^\s]+)/i), webkit = ua.match(/WebKit\/([\d.]+)/i), android = ua.match(/(Android)\s+([\d.]+)/i), ipad = ua.match(/(iPad).*OS\s([\d_]+)/i), ipod = ua.match(/(iPod).*OS

巧妙使用CSS媒体查询(Media Queries)和JavaScript判断浏览器设备类型的好方法

有无数的理由要求我们在任何时候都应该知道用户是使用的什么设备浏览我们的网站——宽屏,普通屏,平板,手机?知道这些特征,我们web应用的CSS和JavaScript才能同步做相应的操作.在给Mozilla Developer Networks改版设计的过程中,我发现使用CSS媒体查询(media queries)虽然非常的有效,但有时,JavaScript却不能及时知道用户浏览设备的状态.浏览网站的用户使用的是桌面电脑,还是平板,还是手机?这对于CSS来说很容易,但CSS却无法将这些信息告诉Jav

js判断设备是iOS还是安卓

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" /> <title></title> <style&g

JS判断设备的类型

利用JS判断浏览器的用户代理,从而获得设备类型.利用这个方法可以获得用户的设备是移动设备还是PC设备. JS代码如下: function browerType() { var sUserAgent = navigator.userAgent.toLowerCase();   //浏览器的用户代理设置为小写,再进行匹配 var isIpad = sUserAgent.match(/ipad/i) == "ipad";   //或者利用indexOf方法来匹配 var isIphoneOs

js 判断设备

varnish判断 if (req.http.User-Agent ~ "Mobile" || req.http.User-Agent ~ "Nokia" || req.http.User-Agent ~ "SAMSUNG" || req.http.User-Agent ~ "SonyEricsson" || req.http.User-Agent ~ "MOT" || req.http.User-Agen

Web移动前端开发-——rem+less+媒体查询,rem+flexble.js+媒体查询

实际开发搞搞起来!!!! rem适配方案 媒体查询+rem+less 基础知识铺垫 第一步,我们需要拿到设计稿,安装设计稿的要求来设置一个合适的html字体大小. 第二步,计算元素大小的取值 页面rem = 页面元素值(设计稿) / (屏幕的宽度/划分的份数) (屏幕的宽度/划分的份数) = html大小 这个算法你也不需要太纠结,按照这个来就是 最后终结一下: 首先我们选一套标准尺寸 750为准 我们用屏幕尺寸 除以 我们划分的份数 得到了 html 里面的文字大小 但是我们知道不同屏幕下得到

js判断设备是都是pc端

function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"); var flag = true; for (var v = 0; v < Agent

iOS 判断设备型号的三种方式

方法一: //***宏定义 #define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO) 方法二: 还有做适配,代码中不要写320和480什么的初始化坐标,要用屏幕高度和宽度初始化#define Screen_height