如何找到移动设备的屏幕空间?

发布于 2024-10-15 12:49:30 字数 158 浏览 5 评论 0原文

我计划为我的网站开发移动版本,我需要考虑所有设备,例如具有不同屏幕尺寸的设备。我试图找到一种方法来获取移动设备的实际宽度,以相应地适应我的移动网站,任何人都可以为这个问题提出解决方案吗?如果我使用 jQuery 或 PHP 找到了这个问题的解决方案,我会非常高兴,因为我正在使用它们来开发我的移动网站。

I'm planing to develop mobile version for my website, I need to consider all the devices like with different screen dimensions. I tried to find out a way to get the real estate width of mobile devise to shoe my mobile site accordingly, can anybody please suggest a solution for this problem. I'll be very happy if I got some solution to this problem using jQuery or PHP because I'm using these to develop my mobile website.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半边脸i 2024-10-22 12:49:30

不要使用 JavaScript,而是使用 CSS3 媒体查询来定位不同的屏幕尺寸,例如:

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

更新: 如果确实有必要,请使用 screen.widthscreen.height< /code> 访问屏幕的宽度和高度。

W3C CSS3 媒体查询

Instead of using JavaScript, use CSS3 media queries to target different screen sizes, for example:

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

Update: If really necessary, use screen.width and screen.height to access the width and height of the screen.

W3C CSS3 Media Queries

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文