Immediate Child selector in LESS

前端 未结 5 1036
天涯浪人
天涯浪人 2020-12-05 03:48

Is there anyway to have LESS apply the immediate child selector ( > ) in its output?

In my style.less, I want to write something like:

.panel {
    .         


        
5条回答
  •  广开言路
    2020-12-05 04:25

    The correct syntax would be following while using '&' would be redundant here.

    .panel{
       > .control{
       }
    }
    

    According to less guidelines, '&' is used to parameterize ancestors (but there is no such need here). In this less example, &:hover is essential over :hover otherwise it would result in syntactic error. However, there is no such syntactic requirement for using '&' here. Otherwise all nestings would require '&' as they are essentially referring to parent.

提交回复
热议问题