简体   繁体   English

为什么在devtools“切换设备工具栏”模式下工作的媒体查询在Chrome浏览器中不起作用?

[英]Why does the media query which works in devtools “toggle device toolbar” mode doesn't work in Chrome browser?

There is no problem when examining the part of my code related to media query in devtools " toggle device toolbar " mode. 在devtools“ toggle device toolbar ”模式下检查与媒体查询相关的部分代码时没有问题。 But after closing the preview, I found that the code didn't work in browser. 但在关闭预览后,我发现代码在浏览器中不起作用。 Why is this happening? 为什么会这样? I think it's related to Chrome browser. 我认为这与Chrome浏览器有关。 Because my code is working properly in Firefox. 因为我的代码在Firefox中正常运行。

// Main CSS

div#top-header {
    grid-area: theader;
    background-color: #FA6938;
    display: flex;
    padding: 0 5px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
}

// This is still working

@media screen and (min-width: 600px) { div#top-header { padding: 0 15px; } }

// This code is running in "toggle device toolbar" mode but not running when I close the preview

@media screen and (min-width: 1120px) { div#top-header { padding: 0 14%; } }

Do you have 你有

<meta name="viewport" content="width=device-width">

In the 'head' of your html ? 在你的HTML的'头'?

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

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