|
|
<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">
悦颐家园网
</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>
|
|