Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何定位<;span>;html标记后的元素?_Html_Css_Css Selectors - Fatal编程技术网

如何定位<;span>;html标记后的元素?

如何定位<;span>;html标记后的元素?,html,css,css-selectors,Html,Css,Css Selectors,如何在一些html标记之后定位span的第一个子级?我的标记如下所示: <div class="gad-help"> <a href="#">AdWords vodič<br><span>osigurajte najbolje rezultate</span></a> </div> 但是当我在标签前面使用标签时,它不会选择它。我认为span:first of type或span:nth of type(

如何在一些html标记之后定位span的第一个子级?我的标记如下所示:

<div class="gad-help">
    <a href="#">AdWords vodič<br><span>osigurajte najbolje rezultate</span></a>
</div>

但是当我在标签前面使用

标签时,它不会选择它。

我认为
span:first of type
span:nth of type(1)
是您要找的。但请注意,它们都将选择其父元素的第一个
span
子元素。在本例中,是锚定标记,而不是
div
元素


因此,如果你想定位第一个锚定标记,你应该通过
来实现。高兴的帮助>a:first of type
(或者
:first child

我认为
span:first of type
或者
span:nth of type(1)
就是你要找的。但请注意,它们都将选择其父元素的第一个
span
子元素。在本例中,是锚定标记,而不是
div
元素

因此,如果您想以第一个锚定标记为目标,您应该通过
。高兴的帮助>a:first of type
(或者在本例中为
:first child

css

css


您需要支持旧浏览器吗?(IE@FabrizioCalderan,不:)在CSS中根本不以标记为目标。CSS在包含元素的DOM上运行。“标记后”和“元素后”的概念完全不同。你应该根据元素来表达你的问题。你需要支持旧浏览器吗?(IE@FabrizioCalderan,不:)在CSS中根本不以标记为目标。CSS在包含元素的DOM上运行。“标记后”和“元素后”的概念完全不同。你应该用元素来表达你的问题。是的,第一种类型的工作很有魅力。我想,我必须更好地学习css伪类。是的,第一种类型的工作很有魅力。我想,我必须更好地学习css伪类。是的,我必须针对第一个类型,而不是第一个孩子。我只针对div内部的两个跨度。是的,我必须针对类型的第一个,而不是第一个孩子。我只针对div内的两个跨度。
.gad-help span:nth-child(1) {
        font-size: 12px;
        text-align: center;
        border: 2px solid red;
        padding: 0px 10px;        
}
.gad-help a span:first-of-type {
    font-size: 12px;
    text-align: center;
    border: 2px solid red;
    padding: 0px 10px;
    color:red;
}