javascript - jQuery 将 div 切片成动画片段

标签 javascript jquery html css slice

是否可以使用 jQuery 和 CSS 将一个 div 一分为二,然后分别为这两部分制作动画?

为了更好地解释,请看这张图:

enter image description here enter image description here

如有任何帮助,我们将不胜感激 - 提前致谢。

最佳答案

您可以像这样用一对容器 div 伪造它: jsFiddle example .

HTML

<div id="top"><div>Some text here</div></div>
<div id="bottom"><div>Some text here</div></div>​

CSS

#top,#bottom {
    background: #333;
    width:200px;
    height:100px;
    position:relative;
    overflow:hidden;
}
#top div {
    position:relative;
    top: 90px;
    color:#eee;
    text-align:center;
}
#bottom div {
    position:relative;
    top: -10px;
    color:#eee;
    text-align:center;
}

jQuery

$('#bottom').delay(2000).animate({
    bottom: '-200px'
},4000);
$('#top').delay(2000).animate({
    top: '-200px'
},4000);

关于javascript - jQuery 将 div 切片成动画片段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11087238/

相关文章:

javascript - 如何使用传单制作中的addClass方法?

php - 确定 Lat/Lng 是否在范围内

javascript - 如何更有效地呈现 Mathjax 内容?

javascript - Youtube 视频在弹出窗口中自动播放

jquery - 使用 jQuery 读取 "data-id"属性

html - HTML5 需要哪些元标记?

javascript - 页面上的多个 ng-app 指令

javascript - 带有按钮和图像的工具提示

javascript - 如何根据元素内容更改颜色?

javascript - 使用 JavaScript 在浏览器中打开文件时写入文件