是否有可能在css伪类中做第n个孩子的第n个孩子?

时间:2015-12-01 16:42:58

标签: css class css-selectors

我基本上想在那一栏中做“第二列然后第二列”。所以在菜单中选择两个,然后两个。

感谢。

footer {
  position: relative;
}

1 个答案:

答案 0 :(得分:2)

当然可以。您可以使用其中一个伪类,如nth-child



        $('.announcementsTitle1').prepend(response.posts.data[0].name);
        $('.announcementsTitle2').prepend(response.posts.data[1].name);
        $('.announcementsTitle3').prepend(response.posts.data[2].name);
        $('.announcementsTitle4').prepend(response.posts.data[3].name);
        $('.announcementsTitle5').prepend(response.posts.data[4].name);

        $('.announcementsText1').prepend(response.posts.data[0].message);
        $('.announcementsText2').prepend(response.posts.data[1].message);
        $('.announcementsText3').prepend(response.posts.data[2].message);
        $('.announcementsText4').prepend(response.posts.data[3].message);
        $('.announcementsText5').prepend(response.posts.data[4].message);

        $('.announcementsText1').append(response.posts.data[0].description);
        $('.announcementsText2').append(response.posts.data[1].description);
        $('.announcementsText3').append(response.posts.data[2].description);
        $('.announcementsText4').append(response.posts.data[3].description);
        $('.announcementsText5').append(response.posts.data[4].description);

        $('.announcementsImage1').attr("src",response.posts.data[0].full_picture);
        $('.announcementsImage2').attr("src",response.posts.data[1].full_picture);
        $('.announcementsImage3').attr("src",response.posts.data[2].full_picture);
        $('.announcementsImage4').attr("src",response.posts.data[3].full_picture);
        $('.announcementsImage5').attr("src",response.posts.data[4].full_picture);]

div.row > div:nth-child(2) > a:nth-child(2){
  background: red;
}




伪类索引以1开头,所以上面的规则说:选择第二个锚点,它是第二个div的子节点,它是行类的任何div的子节点。