[英]Apply CSS to last element of specific class
I want to apply some CSS to the last blog-post. 我想在上一篇博文中应用一些CSS。 The problem is that the last element in the div 'blog-posts' is the same type of element as the 'blog-post' divs.
问题是div“blog-posts”中的最后一个元素与“blog-post”div的元素类型相同。
I've tried: 我试过了:
HTML: HTML:
<div class="blog-posts">
<div class="blog-post"></div>
<div class="blog-post"></div>
<div class="blog-post"></div>
<div class="blog-post"></div>
<div class="f03-456245"></div>
</div>
CSS: CSS:
.blog-post:last-child{
//do some css
}
You may have to do like this: 你可能必须这样做:
.blog-posts div:last-child{
//do some css
}
It is assuming div
is the element. 假设
div
是元素。 It applies for anyother element type p
, span
etc... 它适用于任何其他元素类型
p
, span
等...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.