Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的网站中有一个面包屑,但我想在屏幕小于 480 像素时截断它。我正在使用 mb_strimwidth() 函数,但是如何使用 php 检测屏幕是否小于 480px?
不幸的是,您无法在 PHP 中检索屏幕大小。
但是,您可以使用 JavaScript 检索屏幕大小,将其发送到 PHP 并将其存储在某处以供将来参考(例如在数据库或 cookie 中),然后使用该数据截断。
如果您使用 jQuery,您可以使用.heightand .widthon $(document)or$(window)来获取浏览器和文档的大小。
.height
.width
$(document)
$(window)