[英]How can I select a “last-child of a last-child”?
I'm trying to select the last element contained in the last col-xs-12 div with CSS. 我正在尝试使用CSS选择最后一个col-xs-12 div中包含的最后一个元素。 The thing is that the element is dynamic, so it can be an h2 or h3 etc.
问题是元素是动态的,因此可以是h2或h3等。
<div class="banner-text-img">
<div class="row">
<div class="col-xs-12">
</div>
<div class="col-xs-12">
</div>
<div class="col-xs-12">
<p>...</p>
<h1>...</h1>
</div>
</div>
</div>
I achieved that by selecting tag by tag, but that's not probably the perfect choice. 我是通过逐个标签地选择来实现的,但这可能不是完美的选择。
.banner-text-img div[class^="col"]:last-child h1, .banner-text-img div[class^="col"]:last-child h2... etc.
You can use the asterisk *
to select any element and use :last-child
to target the last element. 您可以使用星号
*
选择任何元素,并使用:last-child
定位最后一个元素。
.col-xs-12 > *:last-child
https://codepen.io/paulbremer/pen/JxEwbx https://codepen.io/paulbremer/pen/JxEwbx
您可以使用星号*
.banner-text-img div[class^="col"]:last-child *:last-child
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.