响应式页面的前端制作

本文详细介绍了如何在不同尺寸的手机上实现适配,包括使用媒体查询、不同分辨率的对应样式表以及如何根据设备宽度、屏幕方向和像素比进行优化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 在<head></head>里加入@media媒体查询

<link rel="stylesheet" media="not all and (min-device-width: 414px) and (max-device-width: 736px) and (orientation: portrait) and (-webkit-min-device-pixel-ratio: 3)" href="dist/css/style.min.css">
<link rel="stylesheet" media="(min-device-width: 414px) and (max-device-width: 736px) and (orientation: portrait) and (-webkit-min-device-pixel-ratio: 3)" href="dist/css/style_iphone6+.min.css">

注:a. device-width是规定设备的尺寸范围

  b. orientation:portrait是规定只能竖屏查看

  c. -webkit-min-device-pixel-ratio是规定这个尺寸范围内的分辨率为3,也就是设计图做到前端手机上要全部缩小3倍。

  附表: 

  • -webkit-min-device-pixel-ratio为1.0
  1. 所有非Retina的Mac
  2. 所有非Retina的iOS设备
  3. Acer Iconia A500 
  4. Samsung Galaxy Tab 10.1
  5. Samsung Galaxy S 

 

  • -webkit-min-device-pixel-ratio为1.3
  1. Google Nexus 7

 

  • -webkit-min-device-pixel-ratio为1.5
  1. Google Nexus S 
  2. Samsung Galaxy S II 
  3. HTC Desire
  4. HTC Desire HD
  5. HTC Incredible S 
  6. HTC Velocity
  7. HTC Sensation 

 

  • -webkit-min-device-pixel-ratio为2.0
  1. iPhone 4
  2. iPhone 4S
  3. iPhone 5
  4. iPad (3rd generation)
  5. iPad 4
  6. 所有Retina displays 的MAC
  7. Google Galaxy Nexus
  8. Google Nexus 4
  9. Google Nexus 10
  10. Samsung Galaxy S III
  11. Samsung Galaxy Note II
  12. Sony Xperia S
  13. HTC One X 

  d. 不同尺寸下,使用不同的样式表。style.cess 和 style_iphone6+.css。

2. 

转载于:https://www.cnblogs.com/JolinChan/p/4368168.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值