wordpress默认的下载按钮还是挺丑的,另外如果文章内附有多网盘文件共享链接,看起来也不容易区分。那怎么比较快速的、一劳永逸的实现下载按钮的美化呢?
1、网站后台找到当前网站主题的公共css样式文件,然后复制下列代码到该文件中:
.i-down-box{
width: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
.idown-btn {
letter-spacing: 0.1em;
cursor: pointer;
font-size: 14px;
font-weight: 700;
line-height: 45px;
width: 23%;
max-width: 160px;
text-decoration: none;
text-transform: uppercase;
margin: 5px;
}
.idown-btn:hover {
text-decoration: none;
}
.i-idown-btn {
--uismLinkDisplay: var(--smLinkDisplay, inline-flex);
display: var(--uismLinkDisplay);
color: #000;
border: 2px solid #000;
border-radius: 5px;
position: relative;
transition-duration: 0.4s;
overflow: hidden;
text-align: center;
}
.i-idown-btn::before,
.i-idown-btn span{
margin: 0 auto;
transition-timing-function: cubic-bezier(0.86, 0, 0.07, 1);
transition-duration: 0.4s;
}
.i-idown-btn:hover{
background-color: #000;
}
.i-idown-btn:hover span{
-webkit-transform: translateY(-400%) scale(-0.1,20);
transform: translateY(-400%) scale(-0.1,20);
}
.i-idown-btn::before{
content: attr(data-sm-link-text);
color: #FFF;
position: absolute;
left: 0;
right: 0;
margin: auto;
-webkit-transform: translateY(500%) scale(-0.1,20);
transform: translateY(500%) scale(-0.1,20);
}
.i-idown-btn:hover::before{
letter-spacing: 0.05em;
-webkit-transform: translateY(0) scale(1,1);
transform: translateY(0) scale(1,1);
}
@media screen and (max-width: 1198px){
.idown-btn{
width: 45%;
}
}
2、文章编辑页面,当需要插入文件下载链接时,切换到文本/html页面,然后复制如下代码并粘贴到合适位置即可:
<div class="i-down-box">
<!--实际使用时下列a标签中的#记得替换为对应网盘文件的下载链接哦-->
<a href="#" class="idown-btn i-idown-btn" data-sm-link-text="点击下载" target="_blank"><span>蓝奏网盘</span></a>
<a href="#" class="idown-btn i-idown-btn" data-sm-link-text="点击下载" target="_blank"><span>天翼网盘</span></a>
<a href="#" class="idown-btn i-idown-btn" data-sm-link-text="点击下载" target="_blank"><span>百度网盘</span></a>
<a href="#" class="idown-btn i-idown-btn" data-sm-link-text="点击下载" target="_blank"><span>123网盘</span></a>
</div>
3、下载按钮效果示意:
使用时,需要分享什么网盘的文件共享链接,修改<a>标签的名字即可。当然,如果有更多网盘链接,多复制几行<a>标签代码即可。
注意:<div>和<a>标签中的class名称不能改动哦。