【问题标题】:What is the meaning of * in the following example? [duplicate]以下示例中的 * 是什么意思? [复制]
【发布时间】:2015-06-18 15:15:34
【问题描述】:

这段代码中*是什么意思?

.descendants * { 
    display: block;
    border: 2px solid lightgrey;
    color: lightgrey;
    padding: 5px;
    margin: 15px;
}
<div class="descendants" style="width:500px;">div (current element) 
  <p class="1">p (child)
    <span>span (grandchild)</span>     
  </p>
  <p class="2">p (child)
    <span>span (grandchild)</span>
  </p> 
</div>

【问题讨论】:

  • "打开以下网址"不,请不要强迫读者这样做。

标签: css


【解决方案1】:

* 在 CSS 中表示“任何元素”。

在上面的示例中,这将针对.descendants 的所有子元素。注意第一个div 中的文本是黑色的,而pspan 的内容是灰色的并且有边框?那是因为 CSS 选择器以这些元素为目标。

【讨论】:

  • 您也可以说“.descendants 的所有后代”,但作为绕口令的设置会更好......
  • 不客气@GopiNath。欢迎来到 StackOverflow。考虑Accepting this answer,如果它解决了您的问题,向其他用户表明这是最有帮助的答案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-20
  • 1970-01-01
  • 2020-10-27
  • 2015-07-15
  • 2018-07-17
  • 2012-08-13
相关资源
最近更新 更多