Elī*_*iņa 1 html css css-selectors
<div class="description_gifts">
<span>Karla Bed</span><img src="images/exit.png" alt="*" /><br />
<span>Quantiy</span><br />
<span>Price</span><br />
<span><strong>Subtotal</strong></span>
</div>
Run Code Online (Sandbox Code Playgroud)
我选择了第一个孩子,但我无法选择下一个跨度的元素
.description_gifts > span:first-child{}
.description_gifts > span:first-child + span{} // dont work
Run Code Online (Sandbox Code Playgroud)
路上有一个img元素和一个br元素.
如果要选择以下所有内容,请span使用~组合器:
.description_gifts > span:first-child ~ span
Run Code Online (Sandbox Code Playgroud)
如果您只想选择下一个span,请:nth-of-type()改用:
.description_gifts > span:nth-of-type(2)
Run Code Online (Sandbox Code Playgroud)
或者只是单步执行img以及br那样的方式:
.description_gifts > span:first-child + img + br + span
Run Code Online (Sandbox Code Playgroud)