[英]CSS's transition's ease-in-out doesn't seem to work
I have a simple overlay of text over an image, darkening the background in the process. 我在图像上有一个简单的文本覆盖层,在此过程中使背景变暗。 I used
transition
with ease-in-out
, but it doesn't seem to ease out properly. 我使用了带有
ease-in-out
transition
效果,但似乎没有适当地缓解效果。
I know that the ease-in-out
should be applied to the thing itself, and not its pseudo of :hover
, but it doesn't seem to want to work. 我知道应该将
ease-in-out
应用于事物本身,而不是应用于:hover
伪事物,但是它似乎并不想工作。 I have tried many ways, moving it around, deleting stuff, adding stuff, but nothing seems to make sense. 我尝试了许多方法,将其移动,删除内容,添加内容,但似乎没有任何意义。 I notice the text do ease out fine, but the
background
with rgba
opacity doesn't co-operate. 我注意到该文本确实可以很好地缓解,但是带有
rgba
不透明度的background
无法配合使用。 It just snaps back :( 它只是回弹:(
Do refer to a live version at http://g4stly.com/staff.html to know what I'm talking about, specifically. 请确实参考http://g4stly.com/staff.html上的实时版本,以明确了解我在说什么。
Thanks in advance! 提前致谢!
My code is as follows: 我的代码如下:
#g4stly { background-image: url('http://g4stly.com/images/users/g4stly.jpg'); } .textFrame { text-align: center; font-size: 20px; color: #DDAA49; text-decoration: none; background-repeat: no-repeat; background-size: cover; border-radius: 30%; width: 250px; height: 250px; } .textFrame p { opacity: 0; height: 75%; margin: 0; border-radius: 30%; transition: opacity 300ms ease-in-out; } .textFrame pa { text-decoration: none; color: #976649; font-size: 25px; } .textFrame:hover p { opacity: 1; background: rgba(0,0,0,0.8); } .textFrame p:first-child { padding: 25% 0 0 0; }
<div id="g4stly" class="textFrame textFrameLeft"> <p><a href="http://steamcommunity.com/profiles/76561198068338533/" target="_blank">g4stly</a><br><br> Owner of everything g4stly related<br> Basically, the boss.</p> </div>
I noticed you updated the code. 我注意到您更新了代码。 Looks like your issue has already been solved.
看来您的问题已经解决。
The .textFrame p
was only applying transition for opacity
, so you couldn't see the background transition. .textFrame p
仅对opacity
应用过渡,因此您看不到背景过渡。 I seed you added background ....
to the transition, you could also do: 我为您添加了
background ....
到过渡,您也可以这样做:
transition: all 1000ms ease-in-out;
Another option would be to move the rgba
background to inside the .textFrame p
, so the background wouldn't suddenly disappear, fading out along with the rest of the element. 另一个选择是将
rgba
背景移到.textFrame p
内部,这样背景不会突然消失,不会随元素的其余部分一起消失。
Hopefully this helps you understand the cause :) 希望这可以帮助您了解原因:)
You had a comma where there should have been a semicolon. 您有一个逗号,应该有一个分号。
transition: background 1000ms ease-in-out;
#g4stly { background-image: url('http://g4stly.com/images/users/g4stly.jpg'); } .textFrame { text-align: center; font-size: 20px; color: #DDAA49; text-decoration: none; background-repeat: no-repeat; background-size: cover; border-radius: 30%; width: 250px; height: 250px; } .textFrame p { opacity: 0; height: 75%; margin: 0; border-radius: 30%; transition: background 1000ms ease-in-out; transition: opacity 1000ms ease-in-out; } .textFrame pa { text-decoration: none; color: #976649; font-size: 25px; } .textFrame:hover p { opacity: 1; background: rgba(0, 0, 0, 0.8); } .textFrame p:first-child { padding: 25% 0 0 0; }
<div id="g4stly" class="textFrame textFrameLeft"> <p><a href="http://steamcommunity.com/profiles/76561198068338533/" target="_blank">g4stly</a><br><br> Owner of everything g4stly related<br> Basically, the boss.</p> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.