sass - 粗鲁的问题。未应用变换效果的过渡
问题描述
有人可以帮我为什么没有应用过渡吗?
html
<div class="box">
<div class="box__faces">
<div class="box__faces--front">
FRONT
</div>
<div class="box__faces--back">
BACK
</div>
</div>
</div>
粗鲁的
.box
{
width: 500px;
height: 500px;
background: #eee;
&__faces
{
transition: all 0.8s ease; // this doesn't seem to be applied.
&--front
{
width:150px;
height:150px;
background: blue;
}
&--back
{
width:150px;
height:150px;
background: red;
transform: rotateY(180deg);
}
}
&__faces:hover &__faces--front
{
transform: rotateY(180deg);
}
&__faces:hover &__faces--back
{
transform: rotateY(0deg);
}
}
我在这里有一个工作代码笔: https ://codepen.io/loganlee/pen/RwNJPdZ ?editors=1100
我希望 .box__faces--front 和 .box__faces--back 的 rotateY 变换都被转换,并且我将转换放置在父元素上,在这种情况下是 .box__faces。
transition: all 0.8s ease; // this doesn't seem to be applied.
谢谢。
解决方案
当您需要在和类上指定它时,您已经设置transition
了类。.box__faces
&--front
&--back
.box
{
width: 500px;
height: 500px;
background: #eee;
&__faces
{
&--front
{
width:150px;
height:150px;
background: blue;
transition: all 0.8s ease;
}
&--back
{
width:150px;
height:150px;
background: red;
transform: rotateY(180deg);
transition: all 0.8s ease;
}
}
&__faces:hover &__faces--front
{
transform: rotateY(180deg);
}
&__faces:hover &__faces--back
{
transform: rotateY(0deg);
}
}
推荐阅读
- javascript - 如何在JS中存储map函数返回的结果数组(React Native)
- java - IllegalStateException:Fragment FiltroOpcao 未附加到上下文。- Android 错误
- regex - 正则表达式:检查字符串是否对应单词编号列表样式
- css - CSS3 媒体查询不能接受更大的最小宽度值
- java - @JsonFormat 在序列化对象时更改时间戳值
- javascript - 如何从 MongoDB 函数中的函数获取变量?
- mysql - 根据其他两个时间戳字段更新日期字段
- git - github SSH 是如何工作的?
- spring-kafka - 多个spring cloud stream应用一起运行
- c - Unix系统调用复制文件夹中所有具有相同扩展名的文件