在 scss 中进行向后嵌套? [英] Make backward nesting in scss?

查看:26
本文介绍了在 scss 中进行向后嵌套?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 scss 中向后嵌套?在 css 中,当我想覆盖 IE 或其他浏览器特定样式的样式时,我喜欢选择器在它覆盖的样式之后.像这样

Is there a way to nest backwards in scss? In css when I want to override style becourse of IE or other browser specific styles I like the selector to be right after the style it selector it overrides. Like this

css

.class-a .class-b{ color: pink }
.ie6 .class-a .class-b{ color: blue}

这在 scss 中可能吗?因为现在我是这样写的(而且我不喜欢)

Is that possible in scss? Because right now I write it like this (and I dont like it)

scss

.class-a{
  .class-b { color: pink }
  .othercss { bla bla bla: sdfsd }
  .fsdfsd { dfsdfs: sdfsd }
  }
}

body.ie7 .class-a .class-b{ color:blue }

推荐答案

您正在寻找 & 父选择器.

You're looking for the & parent selector.

.class-a{
  .class-b { 
    color: pink;
    .ie7 & {
      color: blue;
    }
  }
  .othercss { bla bla bla: sdfsd }
  .fsdfsd { dfsdfs: sdfsd }
}

http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#referencing_parent_selectors_

这篇关于在 scss 中进行向后嵌套?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆