网站屏幕分辨率检测为实际值一半的跨设备技术问题咨询
Hey John, let's tackle this odd problem you're seeing—this smells like a device pixel ratio (DPR) or viewport configuration glitch, especially since it's hitting Chrome on both macOS and Windows but behaving normally in Safari. Here's a step-by-step breakdown of what to check and fix:
1. Verify Your Viewport Meta Tag (Critical!)
Bootstrap 3 relies entirely on the viewport meta tag to handle responsive layouts correctly. If this tag is missing, misconfigured, or overridden, Chrome will calculate the logical window width using your screen's DPR (which is 2x for most modern MacBook Pros). That's why your 1920px physical width is showing up as 960px in jQuery—Chrome's treating it as a "half-size" logical viewport.
Double-check that your <head> includes this exact tag:
<meta name="viewport" content="width=device-width, initial-scale=1">
Even a tiny typo here (like missing initial-scale=1) can throw off Chrome's layout calculations, while Safari might be more forgiving.
2. Test With Native JavaScript Instead of jQuery
jQuery 2.1.1 is pretty old, and its $(window).width() method has known quirks with high-DPI screens and viewport handling. Let's rule out jQuery as the culprit by logging native window width values:
// Open Chrome DevTools console and run these: console.log('Native window width:', window.innerWidth); console.log('Document client width:', document.documentElement.clientWidth);
If these return the correct 1920px value, the problem is definitely jQuery's outdated width calculation. You can either upgrade jQuery to a newer version (3.x+) or use native methods for responsive checks instead.
3. Reset Chrome's Zoom Level
It sounds obvious, but sometimes accidental zoom can cause this exact behavior. Even if you think you're at 100%, reset it to be sure:
- On Mac: Press
Cmd + 0 - On Windows: Press
Ctrl + 0
Since other sites work fine, this is less likely—but it's a quick check worth doing.
4. Check Chrome's Device Emulator Settings
Open Chrome DevTools (F12), go to the Device Toolbar (the phone/tablet icon), and make sure:
- The "Responsive" mode is selected
- The "Device pixel ratio" dropdown is set to "Auto" (not a manual value like 2)
- No custom viewport dimensions are locked in
Sometimes leftover emulator settings can persist even when you're viewing the site normally.
5. Rule Out Bootstrap 3 Edge Cases
Bootstrap 3's media queries are designed around logical viewport widths, but if your viewport is broken, those queries will trigger incorrectly. Since you already removed custom CSS/JS, this is less likely—but you can verify by checking if Bootstrap's default max-width:1024px media query is firing when it shouldn't (use DevTools' Elements > Styles tab to inspect applied styles).
Quick Fix Summary
9 times out of 10, this issue boils down to a missing or misconfigured viewport meta tag. Add that tag first, then test with native JS to confirm the width is correct. If jQuery is still the problem, upgrading it will resolve the DPR-related width calculation bugs.
内容的提问来源于stack exchange,提问作者John Tatu

