我正在尝试使用 CSS 选择最后一个 col-xs-12 div 中包含的最后一个元素。关键是元素是动态的,所以它可以是 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>
我通过逐个选择标签实现了这一点,但这可能不是完美的选择。
.banner-text-img div[class^="col"]:last-child h1, .banner-text-img div[class^="col"]:last-child h2... etc.
最佳答案
您可以使用星号 *
来选择任何元素并使用 :last-child
来定位最后一个元素。
.col-xs-12 > *:last-child
关于html - 如何选择 "last-child of a last-child"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54463596/