Html 选择器:不(:最后一个子项)不使用div child img标记?

Html 选择器:不(:最后一个子项)不使用div child img标记?,html,css,image,selector,Html,Css,Image,Selector,这是我的html代码 <main> <section class="section-about"> <div class="section-about__imagesDiv"> <img src="http://static.messynessychic.com/wp-content/uploads/2015/07/spitfire1.jpg" alt="#" class="tes

这是我的html代码

<main>
        <section class="section-about">
            <div class="section-about__imagesDiv"> 
                <img src="http://static.messynessychic.com/wp-content/uploads/2015/07/spitfire1.jpg" alt="#" class="test ">
                <img src="http://static.messynessychic.com/wp-content/uploads/2015/07/spitfire1.jpg" alt="#" class="test ">
                <img src="http://static.messynessychic.com/wp-content/uploads/2015/07/spitfire1.jpg" alt="#" class="test ">
            </div>
        </section>
    </main>

提前谢谢你!我花了两个小时直到现在,但没有结果

您编写的CSS规则针对的是类
中的元素。关于\uuu imagesDiv
部分不是最后一个子元素,也不是该
中的子元素。由于该类只有一个div,因此该div是最后一个子类,导致您的样式没有任何影响,即使对错误的元素也是如此

例如,您希望以图像为目标

.section-about__imagesDiv > .test:not(:last-child) {
    margin-top: 100rem;
}

您正在选择图像的容器。假设您想给图像留一个边距,请尝试使用以下代码:

.section-about__imagesDiv img{ margin-top: 100rem; }
这将选择除最后一个图像外的所有图像

.section-about__imagesdivimg:not(:last child){margin top:100rem;}

.section-about__imagesDiv img{ margin-top: 100rem; }