简体   繁体   English

基于IE8和REM的媒体查询

[英]IE8 and REM based Media Queries

I would like to base my media queries on REM to support all kinds of browser zooming and/or base/browser font resizing by the user. 我想将我的媒体查询基于REM,以支持用户调整各种浏览器缩放和/或基本/浏览器字体大小。 Ideally down to IE8. 理想情况下,IE8。

Loading jQuery, HTMLshiv, Respond and the REM polyfill and turns out the REM polyfill does not support media queries. 加载jQuery,HTMLshiv,Respond和REM polyfill,结果显示REM polyfill不支持媒体查询。 Don't really understand why though, https://github.com/chuckcarpenter/REM-unit-polyfill/issues/60#issuecomment-135187895 but that is fact. 不知道为什么, https://github.com/chuckcarpenter/REM-unit-polyfill/issues/60#issuecomment-135187895但事实并非如此。

What did Chuck mean with saying " to ignore MQ rules when the polyfill was kicked in, since support would only be required at desktop ". Chuck的意思是“ 在填充polyfill时忽略MQ规则,因为桌面只需要支持 ”。 So when the polyfill kicked in MQ support was dropped? 因此,当polyfill踢入MQ支持时被删除了? And why would MQ support in IE8 only be needed for desktop? 为什么桌面只需要IE8中的MQ支持?

Can it not be that some users don't have the browser window fully open but just one half or quarter of the screen and thus have a smaller screen-width? 可能不是某些用户没有完全打开浏览器窗口,而只是屏幕的一半或四分之一,因此屏幕宽度更小? I don't have my browser at full size most of the time to be able to do work in the other windows etc. 我大部分时间没有全尺寸浏览器能够在其他窗口等工作。

So, now how do you girls and guys do support REM based media queries in IE8? 那么,现在你们如何在IE8中支持基于REM的媒体查询呢?

Would a fallback like mentioned here https://stackoverflow.com/a/21122705/1010918 work? 像这里提到的后备https://stackoverflow.com/a/21122705/1010918工作?

@media screen and (min-width: 26.25rem , min-width: 420px) { ? @media screen and (min-width: 26.25rem , min-width: 420px) {

I don't think this would work (I wish I wish!!) so I am really left with assigning a different stylesheet to IE8 with conditional comments? 认为这会起作用(我希望我希望!!)所以我真的离开了为IE8分配不同的样式表并带有条件评论?

Is this how you go about it? 这是你怎么做的? What are my possibly other solutions? 我可能的其他解决方案是什么?

I have read and thought about all these: 我已阅读并考虑过所有这些:
Basic CSS features not working in IE8 基本的CSS功能在IE8中不起作用
How do you use mobile-first in IE8 你如何在IE8中使用移动优先
media query unlinking IE8 stylesheet 媒体查询取消链接IE8样式表
modernizr for ie8 media query support 现代化的ie8媒体查询支持
What´s best practice to responsive design? 响应式设计的最佳实践是什么? Use % or em and rem? 使用%或em和rem?
IE8 support for CSS Media Query IE8支持CSS Media Query

Check this vid for an example of REM based design. 检查此视频以获取基于REM的设计示例。 I am sure that can also be done with ie8 somehow. 我确信也可以用ie8以某种方式完成。
http://webdesign.tutsplus.com/courses/responsive-web-design-revisited/lessons/what-responsive-means-today-and-what-youll-be-building http://webdesign.tutsplus.com/courses/responsive-web-design-revisited/lessons/what-responsive-means-today-and-what-youll-be-building

IE8 doesn't support media queries either, so it's not that the polyfill is turning them off, it's just that IE8 simply doesn't support them. IE8也不支持媒体查询,因此不是polyfill会关闭它,只是因为IE8根本不支持它们。

What did Chuck mean with saying " to ignore MQ rules when the polyfill was kicked in, since support would only be required at desktop ". Chuck的意思是“ 在填充polyfill时忽略MQ规则,因为桌面只需要支持 ”。 So when the polyfill kicked in MQ support was dropped? 因此,当polyfill踢入MQ支持时被删除了? And why would MQ support in IE8 only be needed for desktop? 为什么桌面只需要IE8中的MQ支持?

He means that IE8 only runs on the desktop, so there's no point supporting it in a responsive way. 他的意思是IE8只能在桌面上运行,所以没有必要以响应的方式支持它。

Can it not be that some users don't have the browser window fully open but just one half or quarter of the screen and thus have a smaller screen-width? 可能不是某些用户没有完全打开浏览器窗口,而只是屏幕的一半或四分之一,因此屏幕宽度更小? I don't have my browser at full size most of the time to be able to do work in the other windows etc. 我大部分时间没有全尺寸浏览器能够在其他窗口等工作。

Okay, so maybe there is a point to supporting it in a responsive way, but it's not a good enough reason for the developer -- he decided that the extra difficulty in adding this support would be too much work to make it worthwhile. 好吧,也许有必要以一种反应灵敏的方式支持它,但这对开发者来说不是一个足够好的理由 - 他认为增加这种支持的额外困难将是太多的工作,使它值得。

He does say in the ticket that if anyone else wants to do the work and submit the code changes, then he'll consider bringing them into the library, but he's not going to do it. 他确实在票证中说如果其他人想要完成工作并提交代码更改,那么他会考虑将它们带入库中,但他不打算这样做。

How much work is it? 这是多少工作?

Well, it's worth pointing out again that IE8 doesn't support media queries. 嗯,值得再次指出IE8不支持媒体查询。 So in order to get MQs at all in IE8, you need to use another polyfill library such as RespondJS. 因此,为了在IE8中完全获取MQ,您需要使用另一个polyfill库,例如RespondJS。

Therefore, the work of making IE8 REMs work with MQs is actually work to make the REM polyfill and RespondJS know about each other and work together -- there's a good chance that you'd need to make changes to both libraries to make it work at all. 因此,使IE8 REM与MQ一起工作的工作实际上是让REM polyfill和RespondJS相互了解并协同工作 - 你很有可能需要对两个库进行更改以使其在所有。 It could be very difficult to do. 这可能非常困难。 I can certainly understand why they decided not to bother. 我当然可以理解为什么他们决定不打扰。

So as things stand, I think you are going to have to accept that what you want to do is not possible in IE8. 事实上,我认为你必须接受在IE8中你不想做的事情。 Unless you want to start hacking around in the polyfill libraries to fix it for yourself. 除非你想开始在polyfill库中进行黑客攻击以自行修复它。

You actually have a real option that works since I ran into the same problem. 实际上你有一个真正的选项,因为我遇到了同样的问题。 Not sure there will be a lot of people interested by this solution in 2017 but it works! 不确定2017年会有很多人对此解决方案感兴趣,但它确实有效!

https://github.com/nbouvrette/remPolyfill https://github.com/nbouvrette/remPolyfill

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

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