gpt4 book ai didi

javascript - 使用旋转效果更改跨度内的文本

转载 作者:行者123 更新时间:2023-11-28 05:42:33 25 4
gpt4 key购买 nike

当 boostrap 轮播滑到新元素时,我正在尝试更改具有特定效果的跨度内的文本。相关文本是轮播中显示的新图像的 ID。

下面的代码可以正常工作:

$('.carousel').bind('slide.bs.carousel', function (e) {
$('#landing-displayed-item').fadeOut();
setTimeout( function(){
$('#landing-displayed-item').text($('.carousel').find('.active').find('img').attr('id'));
$('#landing-displayed-item').fadeIn();
}, 750);
});

但我希望动画不是淡出/淡入,而是类似the one seen here的旋转效果.

因此,我尝试了以下代码,但它不起作用(文本发生变化,根本没有动画):

$('.carousel').bind('slide.bs.carousel', function (e) {
setTimeout( function(){
$('#landing-displayed-item').text($('.carousel').find('.active').find('img').attr('id')).show().css({
"-webkit-transform": " rotate(0) scale(1)",
"-moz-transform": "rotate(0) scale(1)",
"-o-transform": "rotate(0) scale(1)",
"transform": "rotate(0) scale(1)"
});
}, 750);
});

有什么想法吗?

最佳答案

检查这个演示:

var count=0;

$('a').click(function() {
$('div').addClass('rotate')
.delay(500)
.queue(function(n) {
$(this).html("Another Text"+count).removeClass('rotate');
n();
})
count++;
});
div {
font-size: 3em;
font-family: sans-serif;
margin-top: 20px;
transition:all .5s linear;
transform-origin: center;
}
div.rotate {
transform:rotateX(-90deg);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#"> Change Text</a>
<div>This is text for Slide</div>

关于javascript - 使用旋转效果更改跨度内的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37792923/

25 4 0
文章推荐: html - 如何仅使用 CSS 设置