简体   繁体   English

设备宽度和设备高度在桌面浏览器中不能正常工作吗?

[英]Are device-width and device-height not working properly in desktop browsers?

Im trying to experiment with device-width and device-height with my desktop and browser to distinguish to what extent does the property works and differences with the width when it comes to desktop browsers. 我试图在桌面和浏览器上尝试device-widthdevice-height ,以区分该属性在多大程度上起作用以及桌面浏览器的width差异。

For some reason a simple code like this isnt very responsive with desktop browsers particulary firefox. 由于某种原因,像这样的简单代码对桌面浏览器(尤其是Firefox)的响应不是很好。 @media screen and (max-device-width: 500px){ body{ background-color: green; } } @media screen and (min-device-width: 501px){ body{ background-color: red; } }

then i tried resizing the browser only first declaration is being applied and turning to green? 然后我尝试调整浏览器的大小,仅应用第一个声明,然后变为绿色?

anyone know why this is happening? 有人知道为什么会这样吗? specifically does device-width and device-specific properties only work with mobile devices only and not desktop browsers? 特别是设备宽度和特定于设备的属性仅适用于移动设备,而不适用于台式机浏览器吗?

device-width refers to the width of the device itself (or the device's screen resolution) and is most commonly used for targeting specific mobile devices where browsers are not resized. device-width是指设备本身的宽度(或设备的屏幕分辨率),最常用于定位未调整浏览器大小的特定移动设备。 device-width can be used to target laptops as well usually with widths from 1200-1600px. device-width通常也可以用于笔记本电脑,宽度为1200-1600px。

width refers to the width of the browser window (responsive to resizing). width是指浏览器窗口的宽度(响应于调整大小)。

Check out this link for the media queries for common devices: https://css-tricks.com/snippets/css/media-queries-for-standard-devices/ 请查看此链接以查询常见设备的媒体: https : //css-tricks.com/snippets/css/media-queries-for-standard-devices/

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM