iphone5 css样式,iPhone 5的CSS媒体查询

所有这些问题的答案上面列出,使用max-device-width或max-device-height媒体查询,遭受很强的错误:他们也瞄准很多其他受欢迎的移动设备(可能是不需要的,从未测试过,或将在未来上市)。

此查询将适用于任何具有较小屏幕的设备,并且可能会损坏您的设计。

结合类似的设备特定媒体查询(HTC,三星,iPod,Nexus ...),这种做法将启动定时炸弹。对于debigging,这个想法可以让你的CSS成为一个不受控制的spagetti。你永远不能测试所有可能的设备。

请注意,只有媒体查询始终瞄准的iPhone5并没有别的是:

/* iPhone 5 Retina regardless of IOS version */

@media (device-height : 568px)

and (device-width : 320px)

and (-webkit-min-device-pixel-ratio: 2)

/* and (orientation : todo: you can add orientation or delete this comment)*/ {

/*IPhone 5 only CSS here*/

}

注意确切的宽度和高度,而不是最大宽度在这里检查。

现在有什么解决方案?如果你想要写一个网页,将寻找所有可能的设备好,最好的做法是使用降解

/*退化模式 我们正在检查屏幕宽度只有 肯定的是,这将改变从纵向转向景观*/

/*css for desktops here*/

@media (max-device-width: 1024px) {

/*IPad portrait AND netbooks, AND anything with smaller screen*/

/*make the design flexible if possible */

/*Structure your code thinking about all devices that go below*/

}

@media (max-device-width: 640px) {

/*Iphone portrait and smaller*/

}

@media (max-device-width: 540px) {

/*Smaller and smaller...*/

}

@media (max-device-width: 320px) {

/*IPhone portrait and smaller. You can probably stop on 320px*/

}

如果您的网站访问者的30%以上来自手机,把这个方案颠倒,提供移动优先的方法。在这种情况下使用min-device-width。这将加快移动浏览器的网页渲染速度。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值