我们平时访问网站、博客时经常会打开网页后看到弹出一个图片广告。如果作为普通访客可能会略有抵触,但是作为站长,我们却十分需要这样的广告来为网站赚钱贴补一下服务器维护费用。
1、修改 JavaScript 代码:
var popup = document.getElementById('qgg_popup');
var popup_box = document.querySelector('.qgg_popup_box');
var popup_close = document.querySelector('.qgg_popup_close');
// 窗口加载时弹出
window.onload = function() {
popup.style.display = "block";
}
// 点击窗体其他位置时关闭
window.onclick = function(event) {
if (event.target == popup) {
popup.style.display = "none";
}
}
popup_box.onclick = function() {
popup.style.display = "none";
}
// 点击关闭按钮时关闭
popup_close.onclick = function() {
popup.style.display = "none";
}
使用 wordpress 建站的朋友将 JS 代码丢到主题的主 JS 文件中去即可。DUX 主题用户直接丢到主题 js 文件夹下的 main.js 文件中即可。其他程序建站的朋友可以放到自己相应的 JS 文件里。
2、修改 CSS 样式代码:
/* 弹窗广告css 2018-8-29 */
html, body{ margin:0; height:100%; }
#qgg_popup{
position: fixed;
top: 0; left: 0;
display: none;
width: 100%;
height: 100%;
margin: auto;
background: rgba(36, 36, 36, 0.8);
}
.qgg_popup_box {
z-index: 10;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
width: 280px;
height: 396px;
margin: auto;
text-align: center;
}
.qgg_popup_close{
position: relative;
width: 36px;
height: 36px;
background: #fff;
color: #999;
float: right;
font-size: 24px;
text-align: center;
border-radius: 50%;
line-height: 36px;
font-weight: bold;
}
.qgg_popup_close:hover,
.qgg_popup_close:focus {
color: red;
cursor: pointer;
}
.qgg_popup_img{
position:relative;
top: 36px;
left: 0px;
width:240px;
height:360px;
border-radius: 15px;
}
@media (max-width: 640px){
.qgg_popup_close{ display: none; }
}
使用 WordPress 搭建网站的朋友将代码丢到主题的 style.css 文件中即可。DUX 主题丢到 main.css 文件中即可。使用其他网站程序的添加到相应的 css 文件中。
3、修改 html 代码:
这段代码是前端显示的 HTML ,将其放到你想要其显示的页面中即可,比如首页文件 index.php 、文章文件 single.php 中即可。
<!-- 弹窗广告 -->
<div id="qgg_popup">
<div class="qgg_popup_box">
<span class="qgg_popup_close">×</span>
<img class="qgg_popup_img" src="./1.png">
</div>
</div>
注意,代码中“./1.png”这里需要修改成你自己的弹窗广告图片地址。这样就可以实现为网站添加弹窗广告的功能了,有网站需要弹窗功能的朋友可以自己试一下。可能这样小小的修改有时候就能为你网站赚钱增加一个新的渠道!
服务范围 | 1、专业提供WordPress主题、插件汉化、优化、PHP环境配置等服务请详询在线客服 | |||
2、本站承接 WordPress、DedeCMS、ThinkPHP 等系统建站、仿站、开发、定制等服务 | ||||
3、英文模板(主题)安装费用为120元/次,汉化主题首次免费安装(二次安装30元/次) | ||||
售后时间 | 周一至周五(法定节假日除外) 10:00-22:00 | |||
免责声明 | 本站所提供的模板(主题/插件)等资源仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,有部分资源为网上收集或仿制而来,若模板侵犯了您的合法权益,请来信通知我们(Email: [email protected]),我们会及时删除,给您带来的不便,我们深表歉意! |
.demo tbody td a strong{color: #666;}.button_nowbuy,.button_demo {margin: 0em auto;border-style: none;border-width: 0px;padding: 0px;}#qrcode_en,#qrcode_cn{width: 130px;left: 10%;bottom: 250%;}a.button_demo:hover + #qrcode_en{visibility:visible;opacity: 1;bottom: 180%;-webkit-transition: all .4s ease-in-out;-o-transition: all .4s ease-in-out;transition: all .4s ease-in-out;}a.button_demo:hover + #qrcode_cn{visibility:visible;opacity: 1;bottom: 180%;-webkit-transition: all .4s ease-in-out;-o-transition: all .4s ease-in-out;transition: all .4s ease-in-out;}.table.demo{display: none;}
暂无评论内容