PHP广告弹出提示框代码示例:上下循环移动带图片
以下是一个使用PHP实现广告弹出提示框的示例代码,该提示框可以显示图片并上下循环移动。
<!DOCTYPE html>
<html>
<head>
<title>广告弹出提示框</title>
<style>
#adBox {
position: absolute;
top: 0;
left: 0;
width: 300px;
height: 200px;
background-color: #f5f5f5;
border: 1px solid #ccc;
padding: 10px;
overflow: hidden;
}
#adImage {
width: 100%;
height: auto;
}
</style>
<script src='https://code.jquery.com/jquery-3.6.0.min.js'></script>
<script>
$(document).ready(function() {
var adBox = $("#adBox");
var windowHeight = $(window).height();
var adHeight = adBox.height();
var currentPosition = 0;
var direction = 1;
function moveAd() {
currentPosition += direction;
if (currentPosition >= windowHeight - adHeight) {
direction = -1;
} else if (currentPosition <= 0) {
direction = 1;
}
adBox.css('top', currentPosition);
}
setInterval(moveAd, 10);
});
</script>
</head>
<body>
<div id='adBox'>
<img id='adImage' src='path_to_your_image.jpg' alt='广告图片'>
</div>
</body>
</html>
你需要将path_to_your_image.jpg替换为你实际的广告图片路径。这段代码使用了CSS和JavaScript来实现广告提示框的上下循环移动效果。
原文地址: https://www.cveoy.top/t/topic/o7v1 著作权归作者所有。请勿转载和采集!