当我在Google屏幕上var_dump(HTTP_USER_AGENT)
选择设备 IPAD 和 IPAD PRO 时,会得到以下提示:
Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1
Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1
这两者之间没有区别,但分辨率各不相同。我需要根据其iPad或iPad Pro加载文件。
我该如何实现?
答案 0 :(得分:0)
好吧,您必须设置不同的样式表规则来区分设备大小
<html>
<head>
<link rel="stylesheet" media="all and (max-device-width: 1668px) and (device-height: 2388px) and (orientation:portrait)" href="ipad-pro-portrait.css" />
<link rel="stylesheet" media="all and (max-device-width: 1668px) and (device-height: 2388px) and (orientation:landscape)" href="ipad-pro-landscape.css" />
<link rel="stylesheet" media="all and (device-width: 768px) and (device-height: 1024px) and (orientation:portrait)" href="ipad-portrait.css" />
<link rel="stylesheet" media="all and (device-width: 768px) and (device-height: 1024px) and (orientation:landscape)" href="ipad-landscape.css" />
</head>