【问题标题】:Less immediate parent selector without root selector没有根选择器的不太直接的父选择器
【发布时间】:2015-09-07 15:56:26
【问题描述】:

这个更少:

.parent {
  .child {
    h1& {
      color: red;
    }
  } 
}

编译为:

h1.parent .child {color:red};

我需要的是:

.parent h1.child {color:red};

建议赞赏。

我的问题与Less Immediate Parent Selector 的问题相似,但不完全相同。因为选择器是由元素和类名组成的。问题是如何在不影响根选择器的情况下用其元素限定类名。

【问题讨论】:

    标签: less


    【解决方案1】:

    这将适用于这个特定的示例。虽然我很感激它没有回答你的一般问题。

    .parent {
       h1 {
        &.child {
          color: red;
        }
      } 
    }
    

    【讨论】:

    猜你喜欢
    • 2014-03-25
    • 2020-09-06
    • 2011-06-14
    • 1970-01-01
    • 2017-12-11
    • 2011-03-30
    • 2019-09-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多