所有标记后代的选择器 [英] Selector for all a tag descendants

查看:106
本文介绍了所有标记后代的选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这个网页有多个部分:

 < section id =top> ; < section id =tab-banner> 

在这些部分中有许多html和许多层级的嵌套。



我只想说明每个部分的后代的< a> 标签。例如

 #tab-banner a {/ * css here * /} 

如何获取某种类型(a)的所有元素作为具有特定ID的元素的后代?

解决方案

对于所有后代,请使用:

 #tab-banner * 

对于直接后代,请使用:

 #tab-banner> * 



编辑:



更改/澄清问题:



要查找特定类型的所有后代,只需使用该类型而不是 * 。示例:

 #tab-banner a 

所以,你想要的是正确的。如果样式不适用于您期望的元素,那么这些元素实际上不是该部分的后代,或者您有另一个需要优先级的规则。


Sorry if this sounds pretty basic to those who follow the css tag.

The webpage in question has multiple sections:

<section id="top"> ; <section id="tab-banner">

Within these sections there is much html with many levels of nesting.

I just want to say grab all <a> tags that are descendants of each section. E.g.

#tab-banner a { /* css here */ }

How do I say grab all elements of a certain type (a) that are descendents of elements with specific IDs?

解决方案

For all descendants, use:

#tab-banner *

For direct descendants, use:

#tab-banner > *

Edit:

As the op changed/clarified the question:

To find all descendants of a specific type, just use that type instead of *. Example:

#tab-banner a

So, what you are trying is correct. If the style doesn't apply to the elements that you expect, then those elements are actually not descendants of that section, or you have another rule that takes prescedence.

这篇关于所有标记后代的选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆