简体   繁体   English

媒体查询不适用于 Firefox,但适用于 Chrome

[英]Media query not working in Firefox but works in Chrome

This media query code works in Chrome but is not working in Firefox Developer.此媒体查询代码适用于 Chrome,但不适用于 Firefox Developer。

But if I open Web Tools in Firefox and add a line break anywhere in the stylesheet then it works.但是,如果我在 Firefox 中打开 Web Tools 并在样式表中的任何位置添加换行符,那么它就可以工作了。

 #Line_98 { fill: transparent; stroke: rgba(112,112,112,1); stroke-width: 1px; stroke-linejoin: miter; stroke-linecap: butt; stroke-miterlimit: 4; shape-rendering: auto; } .Line_98 { overflow: visible; position: absolute; width: 600px; height: 1px; left: 0px; top: 143.5px; transform: matrix(1,0,0,1,0,0); } #Line_99 { fill: transparent; stroke: rgba(112,112,112,1); stroke-width: 1px; stroke-linejoin: miter; stroke-linecap: butt; stroke-miterlimit: 4; shape-rendering: auto; } .Line_99 { overflow: visible; position: absolute; width: 600px; height: 1px; left: 0px; top: 195.5px; transform: matrix(1,0,0,1,0,0); } #Show_when_view_less_than_line_ { display: none; left: 46px; top: 161px; position: absolute; overflow: visible; width: 255px; height: 16px; text-align: left; font-family: Helvetica Neue; font-style: normal; font-weight: normal; font-size: 14px; color: rgba(160,160,160,1); letter-spacing: 0.5px; } /** show when less than width */ @media (max-width: 600px) { .Show_when_view_less_than_line_ { display: block !important; } } #Show_when_view_more_than_line_ { display: none; left: 46px; top: 222px; position: absolute; overflow: visible; width: 299px; height: 16px; text-align: left; font-family: Helvetica Neue; font-style: normal; font-weight: normal; font-size: 14px; color: rgba(160,160,160,1); letter-spacing: 0.5px; } /** show when more than width */ @media (min-width: 600px) { .Show_when_view_more_than_line_ { display: block !important; } }
 <div id="Responsive_Parts_VI"> <svg class="Line_98" viewBox="0 0 600 1"> <path id="Line_98" d="M 0 0 L 600 0"> </path> </svg> <svg class="Line_99" viewBox="0 0 600 1"> <path id="Line_99" d="M 0 0 L 600 0"> </path> </svg> <div id="Show_when_view_less_than_line_" class="Show_when_view_less_than_line_"> <span>Show when view less than line width</span> </div> <div id="Show_when_view_more_than_line_" class="Show_when_view_more_than_line_"> <span>Show when view more than line width</span> </div> </div>

I'm going to see if this works in the StackOverflow view.我将看看这是否适用于 StackOverflow 视图。

To test resize the browser in Firefox.在 Firefox 中测试调整浏览器的大小。

Here is the full page code (you can save locally):这是完整的页面代码(您可以保存在本地):

https://goonlinetools.com/snapshot/code/#9ioj8td2o5o6gjygd7com3 https://goonlinetools.com/snapshot/code/#9ioj8td2o5o6gjygd7com3

Here is the full page code here:这是完整的页面代码:

 <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Media</title> <style id="applicationStylesheet" type="text/css"> .mediaViewInfo { --web-view-name: Media; --web-view-id: Media; --web-scale-on-resize: true; --web-refresh-for-changes: true; --web-enable-deep-linking: true; } :root { --web-view-ids: Media; } * { margin: 0; padding: 0; box-sizing: border-box; border: none; } #Media { position: absolute; width: 100%; height: 100%; background-color: rgba(255,255,255,1); overflow-x: hidden; overflow-y: auto; --web-view-name: Media; --web-view-id: Media; --web-scale-on-resize: true; --web-refresh-for-changes: true; --web-enable-deep-linking: true; } #Line_99 { fill: transparent; stroke: rgba(112,112,112,1); stroke-width: 1px; stroke-linejoin: miter; stroke-linecap: butt; stroke-miterlimit: 4; shape-rendering: auto; } .Line_99 { overflow: visible; position: absolute; width: 600px; height: 1px; left: 0px; top: 195.5px; transform: matrix(1,0,0,1,0,0); } #Show_when_view_less_than_line_ { display: none; left: 46px; top: 161px; position: absolute; overflow: visible; width: 255px; height: 16px; text-align: left; font-family: Helvetica Neue; font-style: normal; font-weight: normal; font-size: 14px; color: rgba(160,160,160,1); letter-spacing: 0.5px; } /** show when less than width */ @media (max-width: 600px) { .Show_when_view_less_than_line_ { display: block !important; } } #Show_when_view_more_than_line_ { display: none; left: 46px; top: 222px; position: absolute; overflow: visible; width: 299px; height: 16px; text-align: left; font-family: Helvetica Neue; font-style: normal; font-weight: normal; font-size: 14px; color: rgba(160,160,160,1); letter-spacing: 0.5px; } /** show when more than width */ @media (min-width: 600px) { .Show_when_view_more_than_line_ { display: block !important; } } </style> </head> <body> <div id="Media"> <svg class="Line_99" viewBox="0 0 600 1"> <path id="Line_99" d="M 0 0 L 600 0"> </path> </svg> <div id="Show_when_view_less_than_line_" class="Show_when_view_less_than_line_"> <span>Show when view less than line width</span> </div> <div id="Show_when_view_more_than_line_" class="Show_when_view_more_than_line_"> <span>Show when view more than line width</span> </div> </div> </body> </html>

I'm using Firefox Developer 91.0b2 (64-bit) OSX我使用的是 Firefox Developer 91.0b2(64 位)OSX

UPDATE:更新:
The issue was on some code on my side and not the browser.问题出在我这边的一些代码上,而不是浏览器上。

there is an additional css styling you need to do for firefox您需要为 firefox 做一个额外的 css 样式

 @-moz-document url-prefix() { // put your styles here }

or you can use this或者你可以使用这个

 @media all and (min--moz-device-pixel-ratio:0) and (max-width: 680px){ // put your styles here }

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

相关问题 媒体查询只能在Firefox上运行,而不能在Chrome上运行 - Media Query works on Firefox but not on Chrome 媒体查询无法在Chrome中使用,但可以在Firefox中使用 - Media Queries not working in Chrome, works in Firefox 媒体查询不适用于Chrome和设备,但适用于Firefox - media query not working in chrome and device but working on firefox 我的媒体查询不适用于Google Chrome和Firefox - My Media Query is not working on google chrome and firefox @media Query可在IE,Firefox和Edge中使用,但不能在Chrome中使用 - @media Query Working in IE, Firefox, and Edge, but not Chrome 媒体查询在 opera mini 浏览器上不工作,但在 Firefox 和 chrome 浏览器上工作正常 - Media query not working on opera mini browser but works fine on firefox and chrome browser 媒体查询可在chrome上运行,但firefox使用错误的分辨率/查询 - Media query works on chrome but firefox picks up wrong resolution / query @media 查询在 Chrome 中运行良好,但在移动设备上无法运行 - @media query works fine in Chrome, but not working on mobile 媒体查询在 chrome 和 Firefox 桌面上工作,但在移动设备上不工作 - Media query working in chrome and Firefox desktop but not in mobile devices 媒体查询不适用于Chrome,但适用于SO编辑器 - media query isn't working in chrome but works on SO editor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM