CSS CSS选择ul中的所有li

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12464500/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 20:11:10  来源:igfitidea点击:

CSS to select all li in ul

csshtml-lists

提问by Sachin Kainth

I want to write a CSS selector that selects all li elements within a ul element in a document but I don't know how that would be done. Can you help?

我想编写一个 CSS 选择器来选择文档中 ul 元素中的所有 li 元素,但我不知道如何完成。你能帮我吗?

回答by Mark

ul > li {
  /* css styles go here */
}

or

或者

ul li {
  /* css styles go here */
}

the first selects only direct children the second selects all linested within an ul.

第一个只选择直接子级,第二个选择所有li嵌套在ul.

回答by JSK NS

This should work:

这应该有效:

ul li { /*css here */}

回答by maximus ツ

You can use

您可以使用

 ul li {
  /* your code here */
 }