什么是在SASS中处理伪选择器的最佳方法

时间:2013-01-09 18:06:12

标签: sass

只是寻找任何最佳做法/提示。感谢。

1 个答案:

答案 0 :(得分:1)

&字符将允许您在声明中引用父选择器。例如:

a {
  font-weight: bold;
  text-decoration: none;
  &:hover { text-decoration: underline; }
  body.firefox & { font-weight: normal; }
}

编译为:

a {
  font-weight: bold;
  text-decoration: none; }
  a:hover {
     text-decoration: underline; }
  body.firefox a {
    font-weight: normal; }

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