[英]how to use nested transitions with sass
I have this sass transitions: 我有这样的过渡:
.card{
transition: all 0.5s ease;
position: relative;
height: auto;
}
.artistInfo{display: none;}
.card:hover{
box-shadow: 10px 10px rgba(128, 128, 128, 0.37);
margin-top: -3%;
.artistInfo{
display: block;
}
}
the hovers works fine, and the transitions works too except for the .artistInfo transition. 悬停效果很好,除.artistInfo过渡以外,过渡也适用。
You can't animate display property. 您不能为显示属性设置动画。 What you can do is animate opacity 您可以做的是使动画变得不透明
.card {
transition: all 0.5s ease;
position: relative;
height: auto;
}
.artistInfo {
opacity: 0;
position: absolute;
}
.card:hover {
box-shadow: 10px 10px rgba(128, 128, 128, 0.37);
margin-top: -3%;
&+.artistInfo {
opacity: 1;
}
}
http://codepen.io/anon/pen/XMLvqZ http://codepen.io/anon/pen/XMLvqZ
Maybe is because "}" is in the incorrect place for ".card:hover" 可能是因为“。”在“ .card:hover”的错误位置
correct: 正确:
.card{
transition: all 0.5s ease;
position: relative;
height: auto;
}
.artistInfo{display: none;}
.card:hover{
box-shadow: 10px 10px rgba(128, 128, 128, 0.37);
margin-top: -3%;
}
.artistInfo{
display: block;
}
Your nesting is correct you just don't have a transition on your '.artistInfo' class. 您的嵌套是正确的,只是您在'.artistInfo'类上没有任何过渡。 Updating to this should work: 更新到此应该工作:
.card{
transition: all 0.5s ease;
position: relative;
height: auto;
}
.artistInfo{
opacity: 0;
display:none;
transition: all 0.5s ease
}
.card:hover{
box-shadow: 10px 10px rgba(128, 128, 128, 0.37);
margin-top: -3%;
.artistInfo{
opacity: 1;
display: block;
transition: all 0.5s ease
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.