如何选择除CSS中的最后一个孩子外的所有同班孩子

时间:2018-11-09 14:14:29

标签: css

http://jsfiddle.net/Lvq08t6d/

CSS:

div p.test:not(:last-child) {
    background: red;
}

我正在尝试仅选择类p中的所有test,但最后一个除外,这是行不通的。

摆弄:last-of-typehttp://jsfiddle.net/Lvq08t6d/1/对我不起作用。

2 个答案:

答案 0 :(得分:2)

仅CSS不可能。这是使用jQuery的一种方法:

$('.test:not(:last)').css('color', 'red');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
  <p class="test">The first paragraph.</p>
  <p class="test">The second paragraph.</p>
  <p class="test">The third paragraph.</p>
  <p class="test">The fourth paragraph.</p>
  <p class="test"><b>Note:</b> Internet Explorer 8 and earlier versions do not support the :nth-last-child() selector.</p>
  <p>another P here...</p>
</div>

答案 1 :(得分:-1)

在这种情况下,您可以使用最后一个类型

FROM artifactory.cloud.myorg.com/kibana:6.4.2
RUN kibana-plugin install https://artifactory.cloud.myorg.com:443/my-plugin.zip

EXPOSE 5601

CMD ["/usr/local/bin/kibana-docker"]