|
|

楼主 |
发表于 2022-3-23 17:54
|
显示全部楼层
236楼:JS动态生成CSS @keyframes 动画代码——
<style type="text/css">
.wai-zmd { /* 走马灯父框 */
position: absolute;
width: 400px;
height: 300px;
overflow: hidden;
}
.wai-zmd div {/* 走马灯文本框 */
position: absolute;
top: 300px;/*与父框高度同 */
min-height: 20px;
font: normal 20px Sans-Serif;
color: #000;
text-shadow: 1px 1px 1px rgba(0, 0, 0, .25);
}
</style>
<div class="wai-zmd">
<div id="txt-zmd">
I can fly now.
</div>
</div>
<script language="javascript">
zmd();
function zmd(){
var ziBox = document.getElementById('txt-zmd');
var w = ziBox.clientWidth / 2;
var h = ziBox.clientHeight;
var style = document.createElement('style');
var keyframes = '@keyframes fly {to { top: -' + h + 'px;}}';
style.type = 'text/css';
style.innerHTML = keyframes;
ziBox.appendChild(style);
ziBox.style.animation = 'fly 10s linear infinite';
ziBox.style.left = 'calc(50% - ' + w + 'px)'; //元素居中
}
</script>
|
评分
-
| 参与人数 1 | 威望 +50 |
金钱 +100 |
经验 +50 |
收起
理由
|
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|