gpt4 book ai didi

css - 为不同的移动设备配置显示

转载 作者:行者123 更新时间:2023-11-28 12:27:23 24 4
gpt4 key购买 nike

有谁知道根据移动设备的类型获得特定 CSS 样式表的方法吗?我已经研究了几天,除了这段用于 iPhone 的代码外,我什么也没找到。

<link media="only screen and (max-device-width: 480px)" href="iPhone.css" type="text/css" rel="stylesheet" />

这对 iPhone 非常有效,但在所有其他移动设备(安卓、黑莓、诺基亚)上,它仍然显示与我的网站相同的内容。我试过:

<link media="handheld" href="iPhone.css" type="text/css" rel="stylesheet" />

但这似乎对其他移动设备没有任何影响。所以我不确定如何在不影响我实际站点代码的情况下访问黑莓/安卓/诺基亚。

我正在使用 PHP 框架 CodeIgniter 构建我的网站,我查看了这段代码,它应该能够判断它是否正在通过移动设备或浏览器查看。

if ($this->agent->is_browser())
{
$agent = $this->agent->browser().' '.$this->agent->version();
}
elseif ($this->agent->is_mobile())
{
$agent = $this->agent->mobile();
}
else
{
$agent = 'Unidentified User Agent';
}

唯一的问题是我们正在构建的较新的手机将网站呈现为浏览器而不是移动设备(我想,我只测试了 iphone,因为我目前只有它)。那么,是否有人可以解决其他手机平台的问题?

最佳答案

A List Apart有a great article on their Web site所有关于移动样式表。希望对您有所帮助。

关于css - 为不同的移动设备配置显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2590016/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com