CSS :last-child 不选择最后一个元素

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12115255/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 19:58:11  来源:igfitidea点击:

:last-child does not select the last element

csscss-selectors

提问by Yahreen

I want to remove the background from the last figureelement:

我想从最后一个figure元素中删除背景:

@media (min-width: 50em) {
  #mission #press figure {
    padding-left: 0;
    background: url('/assets/img/splash-green.png?1345829368') no-repeat 50% bottom;
  }
  #mission #press figure:last-child {
    background: none;
  }
}

The background still shows up. Am I mis-targeting?

背景仍然显示。我定位错误吗?

回答by SciSpear

I think you might actually be looking for the functionality of last-of-typeinstead of last-child.

我认为您实际上可能正在寻找的功能last-of-type而不是last-child.

LINK

关联