javascript - 如何用Javascript制作表格边框动画?

标签 javascript html animation border css-tables

我想创建一个 Javascript 函数,它将显示 html 中表格的边框,如视频 here. 中所示。
(由于我们无法在这里发布视频,所以我将视频上传到 YouTube 上。请观看。只有 5 秒。)
我的意思是当正文/页面加载时,表格边框将以这种方式显示。 我不知道该怎么做。有人可以帮我编码这个动画吗?

最佳答案

有趣的问题。我会尝试使用 :after 伪元素和 CSS 动画来伪造边框。看看这个演示。

table:after {
    content: '';
    z-index: -1;
    position: absolute;
    top: -3px;
    left: -3px;
    bottom: 100%;
    right: 100%;
    background: green;
    -webkit-animation-name: border;
    -webkit-animation-duration: 3s;
    -webkit-animation-iteration-count: 1;
    -webkit-animation-timing-function: lenear;
    -webkit-animation-fill-mode: forwards;
}

@-webkit-keyframes border {
    from {
        top: -3px;
        top: -3px;
    }
    to {
        bottom: -4px;
        right: -4px;
    }
}

演示:http://jsfiddle.net/dfsq/uSmL3/

作为 CSS 动画的替代方案,您可以使用一些元素(即 div),将其正确放置在表格下方,并使用 javascript 为其宽度和高度设置动画。

关于javascript - 如何用Javascript制作表格边框动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21317262/

相关文章:

javascript - 如何使用 Meteor.http.call

javascript - 在什么情况下 Enumerator 对象 (IE) 和 Iterator 对象 (Fx) 真正有用?

javascript - Ember 复选框单击,更改事件未触发,给出错误

javascript - 仅当在网站中到达该部分时才显示效果

html - 我相对定位的 div 不会对彼此的边界使用react

javascript - @font-face 无法正常工作的问题

javascript - 仅使用部分 jQuery Mobile

windows - 如何在 Windows 桌面上创建暴风雪?

javascript - 在 $animate .then() 方法中访问和更新 Controller 模型 - 使用 'this'

ios - 如何循环动画几次或几秒钟?