为什么我的 :before class 根本没有过渡?聚合物
Why doesn't my :before class transition at all? Polymer
我有使阴影变得可见的代码,但是它没有响应 appearing/disappearing 的任何形式的转换。
有人可以帮忙吗?
CSS实际应用
.wrapper {
position: relative;
z-index: 0;
display: inline-block;
width: 100%;
transition: all 2s;
}
.wrapper.shadow:before {
position: absolute;
z-index: 1;
top: 0;
width: 100%;
height: 10px;
box-shadow: inset 0px 10px 6px -3px rgba(252, 29, 0, 1);
pointer-events: none;
content: "";
opacity: 1;
transition: all 2s;
}
请看我的扩展代码here
如所述here、
You just need to leverage the often forgotten inherit value [..] we can't (yet) directly target pseudo-elements with custom animations.
意味着您需要将 transition: 2s all; 放在 .wrapper .shadow 选择器
中
一开始伪元素不存在,所以你没有什么可以转换的。
用 opacity
或其他东西创建一个隐藏的默认状态,然后当它被打开时它应该淡入视野。
例子
.wrapper {
position: relative;
z-index: 0;
display: inline-block;
width: 100%;
transition: all 2s;
}
.wrapper:before {
position: absolute;
z-index: 1;
top: 0;
width: 100%;
height: 10px;
box-shadow: inset 0px 10px 6px -3px rgba(252, 29, 0, 1);
content: "";
opacity: 0;
transition: all 2s;
}
.wrapper.shadow:before {
pointer-events: none;
opacity: 1;
}
我有使阴影变得可见的代码,但是它没有响应 appearing/disappearing 的任何形式的转换。
有人可以帮忙吗?
CSS实际应用
.wrapper {
position: relative;
z-index: 0;
display: inline-block;
width: 100%;
transition: all 2s;
}
.wrapper.shadow:before {
position: absolute;
z-index: 1;
top: 0;
width: 100%;
height: 10px;
box-shadow: inset 0px 10px 6px -3px rgba(252, 29, 0, 1);
pointer-events: none;
content: "";
opacity: 1;
transition: all 2s;
}
请看我的扩展代码here
如所述here、
You just need to leverage the often forgotten inherit value [..] we can't (yet) directly target pseudo-elements with custom animations.
意味着您需要将 transition: 2s all; 放在 .wrapper .shadow 选择器
中一开始伪元素不存在,所以你没有什么可以转换的。
用 opacity
或其他东西创建一个隐藏的默认状态,然后当它被打开时它应该淡入视野。
例子
.wrapper {
position: relative;
z-index: 0;
display: inline-block;
width: 100%;
transition: all 2s;
}
.wrapper:before {
position: absolute;
z-index: 1;
top: 0;
width: 100%;
height: 10px;
box-shadow: inset 0px 10px 6px -3px rgba(252, 29, 0, 1);
content: "";
opacity: 0;
transition: all 2s;
}
.wrapper.shadow:before {
pointer-events: none;
opacity: 1;
}