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

底部导航

在style.css文件中增加css

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
.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文件中之前增加以下代码

1
2
3
4
5
6
7
8
9
<?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 上面的#号就是菜单链接地址(自己替换)

原文链接:https://xiaohost.com/1645.html,转载请注明出处。
0

评论0

请先