html css visibility,html - CSS Visibility Animation Not working - Stack Overflow

本文探讨了如何使用CSS动画控制元素的可见性,特别指出通过`visibility`属性的过渡效果可能产生的误解。作者介绍了如何正确运用关键帧来实现元素在5秒内先隐藏再突然显示,并给出了相关示例和博客链接。
摘要由CSDN通过智能技术生成

A CSS transition or animation on the visibility property keeps the element visible

for the duration of the transition and then abruptly applies the new value.

(assuming the current spec and as long as no special timing function is used.)

Transitions/Animations on visibility do not show a gradually changing

visual effect, however as I read the question the idea is indeed

to keep the element hidden till the 5th second.

Your CSS animation specifies a first transition from 0% to 50%

turning from hidden to visible which shows the element according

to the rule above and then you specify a transition from 50% to

100% from visible to hidden, which also shows the element while

playing. So the element it permanently visible.

By specifying

@keyframes toggle {

from {

visibility:hidden;

}

50% {

visibility:hidden;

}

to {

visibility:visible;

}

}

the element will stay hidden until 50% and then abruptly appear.

To hide it at the end, you need to add visibility:hidden to

the main style sheet rule not to the keyframes.

Also see my blog post on CSS transition visibility

http://www.taccgl.org/blog/css-transition-visibility.html#Appearance_CSS_Visibility

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值