【发布时间】:2013-05-30 02:16:59
【问题描述】:
您将如何编写此代码以符合 SASS?
.fader { display: inline-block; }
.fader img:last-child {
position: absolute;
top: 0;
left: 0;
display: none;
}
基本上我只是在复制这个例子,在一个图像中淡入另一个(found here.)
他的 JFiddle 示例:http://jsfiddle.net/Xm2Be/3/
但是他的示例是纯 CSS,我正在使用 SASS 开发一个项目,但不确定如何正确翻译它。
我的代码
请注意,在下面的示例中,img 悬停无法正常工作(两个图像都显示并且没有发生翻转淡入动作)
我的 CodePen: http://codepen.io/leongaban/pen/xnjso
我试过了
.try-me img:last-child & .tryme img:last-of-type
但是 : 抛出 SASS 编译错误,下面的代码可以工作
.try-me img last-of-type {
position: absolute;
top: 0;
left: 0;
display: none;
}
但是它吐出的 CSS 对我没有帮助:
.container .home-content .try-me img last-of-type {
position: absolute;
top: 0;
left: 0;
display: none;
}
更新:工作 Codepen:
【问题讨论】:
标签: css sass css-selectors