以下是用PHP实现的广告弹出提示框的示例代码,它可以显示图片并让广告内容上下循环移动。

<!DOCTYPE html>
<html>
<head>
    <style>
        .ad-container {
            position: fixed;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            width: 300px;
            height: 300px;
            background-color: #f1f1f1;
            border: 1px solid #ccc;
            overflow: hidden;
        }
        
        .ad-container img {
            display: block;
            width: 100%;
            height: auto;
            animation: moveupdown 3s linear infinite;
        }
        
        @keyframes moveupdown {
            0% {
                transform: translateY(0);
            }
            50% {
                transform: translateY(-50%);
            }
            100% {
                transform: translateY(0);
            }
        }
    </style>
</head>
<body>
    <div class="ad-container">
        <?php
            $ads = [
                'ad1.jpg',
                'ad2.jpg',
                'ad3.jpg'
            ];
            $ad = $ads[array_rand($ads)];
        ?>
        <img src="<?php echo $ad; ?>" alt="Ad">
    </div>
</body>
</html>

你可以将广告图片存储在与PHP文件相同的目录中,并用<img>标签的src属性指定广告图片的路径。在示例代码中,广告图片会随机选择一个进行展示,并通过CSS动画实现上下循环移动。你可以根据需要修改CSS样式和图片路径。

PHP广告弹出提示框:带图片和循环移动效果

原文地址: https://www.cveoy.top/t/topic/o7vZ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录