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

:nth-child()的使用 #6

Open
yurensmile opened this issue Apr 17, 2019 · 0 comments
Open

:nth-child()的使用 #6

yurensmile opened this issue Apr 17, 2019 · 0 comments
Labels

Comments

@yurensmile
Copy link
Owner

el:nth-child(2) {} //选取el的第二个标签
el:nth-child(n+3) {} //选取el的大于等于3的标签

例子:

<div class="bouncing-loader">
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>
.bouncing-loader {
  display: flex;
  justify-content: center;
}
.bouncing-loader > div:nth-child(1) {
  width: 2rem;
  height: 2rem;
  border: 2px solid black;
  background-color: blue;
}
.bouncing-loader > div:nth-child(2) {
  width: 2rem;
  height: 2rem;
  border: 2px solid black;
  background-color: gray;
}
.bouncing-loader > div:nth-child(n+3) {
  width: 2rem;
  height: 2rem;
  border: 2px solid black;
  background-color: red;
}

结果:
image

@yurensmile yurensmile added the css label Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant