gpt4 book ai didi

javascript - 使用 jquery 的简单 .animate

转载 作者:行者123 更新时间:2023-12-02 15:02:22 24 4
gpt4 key购买 nike

出于某种原因,每次我尝试在代码中实现 jquery 时,它都不起作用。我知道编写 jquery 的基础知识,并查找我正在尝试执行的操作,但显然即使我的代码与在线示例完全相同,也永远无法正确执行。

我在这里想做的就是让 #time 从屏幕外滑动到页面加载时的正常位置。我尝试了 .slideDown 和 .animate(顶部)

<div id="time">
<h1>Good Evening</h1>
</div>



#time {
width: 100%;
height: 50px;
background-color: #000;
}

#time h1 {
color: #D4AF37;
font-size: 38px;
font-family: 'Arimo', sans-serif;
font-weight: 700;
text-align: center;
letter-spacing: 5px;
font-style: italic;
margin-top: 0px;
line-height: 50px;

}

$(function() {
$('#time').animate({
top: '50px'), 200
});
});

https://jsfiddle.net/d025dsqb/

最佳答案

请在此处查看工作解决方案:

https://jsfiddle.net/aq9hszmv/2/

$(function() {
$('#time').animate({
top: '0px'}, 2000
);
});

#time {
width: 100%;
height: 50px;
background-color: #000;
top: -50px;
position: absolute;
}

关于javascript - 使用 jquery 的简单 .animate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35341555/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com