【问题标题】:How to extend a media query with a class如何使用类扩展媒体查询
【发布时间】:2013-09-30 12:46:06
【问题描述】:

我尝试通过javascript切换显示模式。

假设我尝试了一个带有“display_mobile”类的 html 元素:

@media only screen and (max-width: 767px), html.display_mobile {
/* mobile mode definitions */
}

但这不起作用。 知道如何解决这个问题吗?

【问题讨论】:

  • 我不太喜欢媒体查询,但它们不是专门为避免这样做而设计的吗?

标签: media-queries extending


【解决方案1】:

像这样。媒体查询不允许在条件中使用选择器。

@media only screen and (max-width: 767px) {
    html.display_mobile .any-definition {}
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-17
    • 2014-02-28
    • 2019-09-23
    • 2013-01-28
    • 1970-01-01
    • 1970-01-01
    • 2017-04-21
    相关资源
    最近更新 更多