以下是基于 WHMCS 的 Logam 框架编写的一个淡入淡出的弹窗的示例代码:

1. 首先,在 WHMCS 模板中的'header.tpl'文件中添加以下代码,用于加载所需的 CSS 和 JavaScript 文件:

<link rel="stylesheet" type="text/css" href="path/to/animate.css">
<script src="path/to/jquery.min.js"></script>

2. 在'header.tpl'文件的末尾添加以下 JavaScript 代码,用于控制弹窗的显示和隐藏:

<script>
$(document).ready(function() {
    // 绑定弹窗显示按钮的点击事件
    $('#showPopupButton').click(function() {
        $('.popup').fadeIn('slow');
    });

    // 绑定弹窗关闭按钮的点击事件
    $('#closePopupButton').click(function() {
        $('.popup').fadeOut('slow');
    });
});
</script>

3. 在需要弹窗的页面中,添加以下 HTML 代码,用于创建弹窗的内容和按钮:

<div class="popup">
    <div class="popup-content">
        <h2>这是一个弹窗</h2>
        <p>这是弹窗的内容。</p>
        <button id="closePopupButton">关闭</button>
    </div>
</div>

<button id="showPopupButton">显示弹窗</button>

4. 最后,在 WHMCS 模板的'style.css'文件中添加以下 CSS 代码,用于设置弹窗的样式:

.popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
}

.popup-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.popup-content h2 {
    margin-top: 0;
}

.popup-content p {
    margin-bottom: 20px;
}

.popup-content button {
    display: block;
    margin: 0 auto;
}

请注意,上述代码中的“path/to”应替换为实际的文件路径。

通过以上代码,点击“显示弹窗”按钮时,将会以淡入的效果显示弹窗,点击弹窗中的“关闭”按钮时,将以淡出的效果隐藏弹窗。

使用 WHMCS Logam 框架创建淡入淡出弹窗

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

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