首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >@media inside @media &糟糕的SASS解析

@media inside @media &糟糕的SASS解析
EN

Stack Overflow用户
提问于 2012-01-17 21:32:59
回答 1查看 424关注 0票数 1

我有以下几点看法:

代码语言:javascript
运行
复制
.branded
  @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2)
    @media screen and (orientation:portrait)
      background-image: url("../img/fbc/citroen_640x960.jpg")
    @media screen and (orientation:landscape)
      background-image: url("../img/fbc/citroen_960x640.jpg")
    background-size: 50%

并将其解析为以下CSS:

代码语言:javascript
运行
复制
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) {
    .branded {
        background-size: 50%;
    }
}

@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) and screen and (orientation:portrait) {
    .branded {
        background-image: url("../img/fbc/citroen_640x960.jpg");
    }
}

@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) and screen and (orientation:landscape) {
    .branded {
        background-image: url("../img/fbc/citroen_960x640.jpg");
    }
}

我发现它不工作,并且我在这一行得到一个错误:

代码语言:javascript
运行
复制
@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) and screen and (orientation:landscape) {

为什么会这样?为什么SASS解析器会创建带有错误的CSS?是我的错还是SASSes?

EN

回答 1

Stack Overflow用户

发布于 2012-02-08 14:09:33

我也不认为在标准的CSS中混合@media是可能的,但是nesting in SASS是可能的。

我可能错了,但我认为错误可能来自于混合:@media only screen和(-webkit-min-device-pixel-ratio: 2),only screen和(min-device-pixel-ratio: 2)和screen和(screen:横向)

尝尝这个?

代码语言:javascript
运行
复制
.branded
  @media only screen
    @media (-webkit-min-device-pixel-ratio: 2), (min-device-pixel-ratio: 2)
      background-size: 50%
      @media (orientation:portrait)
        background: url("../img/fbc/citroen_640x960.jpg")
      @media (orientation:landscape)
        background: url("../img/fbc/citroen_960x640.jpg")
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8895490

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档