通过一段简单的代码,我们可以实现在文章页面显示文章发布超过多久的提醒,方便自己及用户注意。下面就直接上代码。
直接在POST.PHP文件合适的位置放入以下代码:
<div class="j-alt warning">
本文最后更新于<?php echo date('Y年m月d日' , $this->modified);?>,已超过<?php echo floor((time()-($this->modified))/86400);?>天没有更新。如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!
</div>
然后在CSS文件放入以下美化代码:
.j-alt {
width: 100%;
padding: 8px 15px 8px 35px;
border-radius: 4px;
position: relative;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
transition: opacity 0.2s;
font-size: 13px;
margin: 20px 0;
}
.j-alt.warning {
background-color: #fdf6ec;
color: #e6a23c;
}
.j-alt::before {
content: '';
position: absolute;
top: 50%;
left: 10px;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
width: 20px;
height: 18px;
vertical-align: top;
}
.j-alt.warning::before {
background-image: url(图标地址);
background-repeat: no-repeat;
background-position: center center;
}
Comments | 1条评论
该文章已经关闭评论