【问题标题】:jquery animation to move a p tag up certain heightjquery动画将p标签向上移动一定高度
【发布时间】:2013-04-26 06:30:10
【问题描述】:

动画在这里工作,但我只想将 facebook 移动 10% 顶部并留下,但它消失了,我希望我在动画后留下来并慢慢登录表单淡入。

<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script> 
$(document).ready(function(){
$("div.login").hide();
$("p").slideUp(1000);
$("div.login").fadeIn(3000);
});
</script>

<style type="text/css">
*{margin:0; padding:0}
html, body {
color: #F00;
background-color: #333;
display: block;
height: 100%;
width: 100%;
}
.logo{width:100%; height:40%;}
p{font-size:200%; text-align:center; padding-top:20%}
.login{width:100%; height:60%; text-align:center;}
</style>
</head>
<body>

<div class="logo"><p>facebook</p></div>
 <div class="login">
    <ul>
        <li><label for="username">Username</label><input type="text"    placeholder="you@email.com" autofocus required /></li>
        <li><label for="Password">Password</label><input type="password" placeholder="you@email.com" autofocus required /></li>
        <li><button>Login</button></li>
    </ul>
</div>
</body>
</html>

【问题讨论】:

  • 也许不是我要问的,但你为什么要这样惹恼用户?另外..隔离你的东西。不要在同一个文件中混用 css、html 和 javascript。
  • 您是否要针对 Facebook 登录进行网络钓鱼?
  • 我对此表示怀疑,因为 Facebook 不会为毫无意义的褪色而烦恼(我认为?)。
  • 尝试为您的 div 使用绝对位置。

标签: jquery html css responsive-design


【解决方案1】:
 .slide up()

Description: Hide the matched elements with a sliding motion.

JQuery Docs

如果我正确理解您的问题,您实际上想使用.animate()

$('p').animate({'top':'-50px'}, 1000);

调整以适应元素的高度

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-27
    • 2011-06-03
    • 1970-01-01
    • 1970-01-01
    • 2021-10-21
    • 2016-08-25
    • 2012-03-01
    • 1970-01-01
    相关资源
    最近更新 更多