HTML公告浮窗
实现效果
实现代码
css
.web_notice {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
z-index: 99999;
}
.web_notice_content {
position: fixed;
top: 50%;
left: 50%;
width: 550px;
background: rgb(36, 46, 59);
transform: translate(-50%, -50%);
border-radius: 40px;
padding: 50px 40px;
color: rgb(255, 255, 255);
word-wrap: break-word;
}
.web_notice_title {
color: rgb(173, 134, 252);
display: flex;
flex-direction: column;
align-items: center;
}
.web_notice_text {
margin-bottom: 20px;
}
.web_notice_buttons {
display: flex;
justify-content: space-between;
}
.web_notice_button {
display: block;
background: rgb(173, 134, 252);
color: #FFF;
text-align: center;
font-weight: bold;
font-size: 19px;
line-height: 49px;
border-radius: 5px;
width: 40%;
}
.support_button {
float: left;
}
.acknowledge_button {
float: right;
}
javascript
function closeWebNotice() {
document.querySelector('.web_notice').remove();
}
html
<div class="web_notice">
<div class="web_notice_content">
<h2 class="web_notice_title">本站已开通爱发电赞助平台</h2>
<p class="web_notice_text">
为维护网站的正常运作,本站设立独立服务器,并开通了新的运营商宽带,产生了不小的费用。作者为个人开发者,没有团队,费用均由一人承担。现在开通高级订阅通道,具体信息:<br>
1. 订阅费用:5元/月。<br>
2. 订阅期间:<br>
a. 可享受最新的内测功能;<br>
b. 解锁高级功能使用权;<br>
c. 让作者买杯奶茶回回血。
</p>
<div class="web_notice_buttons">
<a href="https://afdian.net/order/create?plan_id=" class="web_notice_button support_button">
支持一下
</a>
<a class="web_notice_button acknowledge_button" onclick="closeWebNotice()">
我知道了
</a>
</div>
</div>
</div>
整合形式
可直接内嵌在html中
<div class="web_notice" style="position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:99999;">
<div style="position:fixed;top:50%;left:50%;width:550px;background:rgb(36,46,59);transform:translate(-50%,-50%);border-radius:40px;padding:50px 40px;">
<div style="color:#FFF;word-wrap:break-word;"><h2 style="color:#AD86FC;display:flex;flex-direction:column;align-items:center;">本站已开通爱发电赞助平台</h2>为维护网站的正常运作,本站设立独立服务器,并开通了新的运营商宽带,产生了不小的费用。作者为个人开发者,没有团队,费用均由一人承担。现在开通高级订阅通道,具体信息:<br>1,订阅费用:5元/月。<br>2,订阅期间:<br> a,可享受最新的内测功能;<br> b,解锁高级功能使用权;<br> c,让作者买杯奶茶回回血。</div>
<div>
<a href="https://afdian.net/order/create?plan_id=" style="display:block;background:#AD86FC;color:#FFF;text-align:center;font-weight:bold;font-size:19px;line-height:49px;margin-top:11px;border-radius:5px;width:40%;float:left;">支持一下</a>
<a style="user-select:none;display:block;background:#AD86FC;color:#FFF;text-align:center;font-weight:bold;font-size:19px;line-height:49px;margin-top:11px;border-radius:5px;width:40%;float:right;" onclick="javascript:document.querySelector('.web_notice').remove()">我知道了</a>
</div>
</div>
</div>