首页 » Wordpress »

移动端增加底部导航菜单代码

移动端增加底部导航菜单代码

在style.css文件中增加css

.mobile-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: #FFF;
z-index: 9;
border-top: 0px solid #e0e0e0;
width: 100%;
display: table;
box-shadow: 0 0 50px 0 #748594;
}
.mobile-bar a {
cursor: pointer;
color: #5D656B;
display: table-cell;
text-align: center;
text-decoration: none;
}
.mobile-bar a i {
margin-top: -2px;
text-align: center;
vertical-align: middle;
background-repeat: no-repeat;
background-size: 100%;
display: inline-block;
width: 38px;
height: 38px;
}
.mobile-bar a span {
display: block;
color: #333;
margin-top: -6px;
font-size: 14px;
}
a.i-buy span {
color: #fff;
background-color: #ff5e5c;
padding: 15px 4px;
border-radius: 50px;
}
a.i-buy {
background: #FFFFFF;
}
a.i-home i {
background-image: url(./images/i-home.png);
}
a.i-cat i {
background-image: url(./images/i-cat.png);
}
a.i-my i {
background-image: url(./images/i-my.png);
}
a.i-buy i {
background-image: url(./images/i-my.png);
}
a.i-cat.burger-menu {
position: initial !important;
line-height: inherit;
width: initial;
height: inherit;
font-family: inherit;

在主题footer.php文件中之前增加以下代码

<?php
if(wp_is_mobile()&&!is_single()){?>
<div class="mobile-bar">
<a class="i-home" href="/"><i></i><span>首页</span></a>
<a class="i-cat burger-menu"><i></i><span>菜单</span></a>
<a class="i-my" href="#"><i></i><span>菜单1</span></a>
<a class="i-buy" href="#"><i></i><span>菜单2</span></a>
</div>
<?php }?>

代码说明:
1 菜单名称修改成你需要的名称
2 上面的#号就是菜单链接地址(自己替换)

本文标签:

相关文章推荐

转载请保留,转载自:老牛博客
原文地址 http://xiaohost.com/1645.html

发表评论