last-child and last-of-type not working in SASS

前端 未结 3 1449
梦毁少年i
梦毁少年i 2021-01-01 15:16

How would you write this to be SASS compliant?

.fader { display: inline-block; }
.fader img:last-child {
    position: absolute;
    top: 0;         


        
3条回答
  •  耶瑟儿~
    2021-01-01 16:05

    Neither of the above worked for me, so.

    last-of-type only plays nice with elements, you can select things with classes all you like but this gets handled by the elements. So say you have the following tree:

    To get to the last div with the class of middle, doesn't work using last-of-type.

    My workaround was to simply change the type of element that somethingelse was

    Hope it helps someone out, took me a while to figure that out.

提交回复
热议问题