如何在Vue过渡中去除过渡延迟?
P粉757432491
P粉757432491 2023-08-17 17:36:49
0
1
326
<p>我正在使用Vue来实现当鼠标悬停在图片上时,通过动画将文本框向上移动并淡入。动画效果是正确的,但是它有一个轻微的延迟才开始。我希望文本框在图片悬停时能够平滑且立即地开始淡入和向上移动。当光标离开时,文本框能够正确地淡出和向下移动。</p> <pre class="brush:php;toolbar:false;">template: ` &lt;div&gt; &lt;div class="attribute-icons" v-for="(item, i) in techBadges" :key="'tech_' + i"&gt; &lt;img @mouseenter="hoverStart(i)" @mouseleave="hoverEnd" class="attribute-icon" width="30px" height="30px" :src="badges[item].imageSrc" :alt="badges[item].alt"/&gt; &lt;Transition&gt; &lt;p v-show="hoveredIndex === i"&gt;{{ badges[item].description }}&lt;/p&gt; &lt;/Transition&gt; &lt;/div&gt; &lt;/div&gt; `, methods:{ hoverStart(i){ this.hoveredIndex = i; }, hoverEnd(){ this.hoveredIndex = null; } },</pre> <pre class="brush:php;toolbar:false;">.attribute-icons { margin-top: 5px; position:relative; transition-delay: 0s; img { width: 28px; height: 28px; margin-right: 8px; transition: 0.24s; transition-delay: 0s; } p { position: absolute; top: 20px; width:19vw; max-width:350px; min-width:175px; background: #0088ce; color: #ffffff; z-index: 1; border-radius: 5px; padding: 5px 10px; box-shadow: 0 0 18px rgba(2, 2, 2, 0.14); pointer-events: none; font-weight: 500; font-size: 13px; transition: 0.24s ease; transition-delay: 0s; @media(max-width:1100px){ width:25vw; } @media(max-width:991px){ width:36vw; } } .v-enter-from{ opacity: 0; transform: translateY(10px); transition: opacity 0.24s ease, transform 0.24s ease; transition-delay: 0s; }; .v-enter-active{ transition-delay: 0s; transition: opacity 0.24s ease, transform 0.24s ease; transform: translateY(4px); }; .v-enter-to{ }; .v-leave-from{ transform: translateY(10px); }; .v-leave-active{ transition: opacity 0.24s ease, transform 0.24s ease; transform: translateY(10px); }; .v-leave-to{ opacity:0; };</pre> <p>我尝试给所有元素添加transition-delay: 0s,但没有起作用。</p>
P粉757432491
P粉757432491

membalas semua(1)
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!