Space in less loop

这一生的挚爱 提交于 2019-12-23 01:35:10

问题


I have this :

.loop(@index) when(@index =< @to) {
    .page-@{index} {
        nav{
            ul{
                li:nth-child(@{index}){
                    background:#fff;
                }
            }
        }
    }
    .loop(@index + 1);
}

It seems to have a problem, because the output of my css is :

ul li:nth-child( 2) {
  background: #fff;
}
ul li:nth-child( 3) {
  background: #fff;
}

it creates a space in the pseudo selector and it doesn't work. Any ideas to remove this space ? Thanks


回答1:


It's a bug. A workaround is to set the identifier via temporary variable, e.g.:

ul {
    @li: ~"li:nth-child(@{index})";
    @{li} {
        background: #fff;
    }
}


来源:https://stackoverflow.com/questions/23064609/space-in-less-loop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!