Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

less循环 #27

Open
xiaotiandada opened this issue Jan 19, 2021 · 0 comments
Open

less循环 #27

xiaotiandada opened this issue Jan 19, 2021 · 0 comments

Comments

@xiaotiandada
Copy link
Owner

2019-08-16 11:55:30

使用递归调用来循环

less 编译前

.loop(@n) when (@n > 0) {
  div:nth-of-type(@{n}){
    width: (@n*10px);
    height: 40px;
    background: red;
    margin: 10px;
    font-size: 12px;
  }
  .loop(@n - 1);
}

.loop(5);

css 编译后

div:nth-of-type(5) {
  width: 50px;
  height: 40px;
  background: red;
  margin: 10px;
  font-size: 12px;
}
div:nth-of-type(4) {
  width: 40px;
  height: 40px;
  background: red;
  margin: 10px;
  font-size: 12px;
}
div:nth-of-type(3) {
  width: 30px;
  height: 40px;
  background: red;
  margin: 10px;
  font-size: 12px;
}
div:nth-of-type(2) {
  width: 20px;
  height: 40px;
  background: red;
  margin: 10px;
  font-size: 12px;
}
div:nth-of-type(1) {
  width: 10px;
  height: 40px;
  background: red;
  margin: 10px;
  font-size: 12px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant