媒体查询iphone6、iphone6 plus,js判断设备型号
2015-06-16 11:03
519 查看
/* 兼容问题*/
@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;
@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;
相关文章推荐
- js 变量作为 对象的属性
- JS:跟随鼠标移动的图片,兼容IE与DOM浏览器(已在实际中用懂啊)
- Java 6 中也可以运行 javascript 喽 (转)
- javascript传入参数,引用or形参
- js class模型 关于 初始化key值为非基本类型是 实例之间是引用该变量
- 简述JavaScript对传统文档对象模型的支持
- 纯javascript实现四方向文本无缝滚动效果
- 从json_encode过来的的字符串被返回到html页面时的解析
- Extjs Grid 中文排序
- 201506160850_《JavaScript权威指南(第六版)——方法调用》(P168-171)
- 简述JavaScript的正则表达式中test()方法的使用
- 我也谈javascript正则匹配
- Javascript之typeof与instanceof
- javascript this 关键字以及四种函数调用模式
- javascript 哈希表(hashtable)的简单实现
- 在JavaScript的正则表达式中使用exec()方法
- JavaScript变量以及在HTML中的使用
- JavaScript正则表达式之multiline属性的应用
- DataContractJsonSerializer和JavaScriptSerializer内部实现差异
- JSON详解