仿微信底部自定义菜单 移动web
最近在做微信开发,要实现微信公众号改版—-改成微官网形式,即移动web页面中实现公众号的主页面,包括了公众号的菜单在底部显示
本文针对仿公众号底部菜单这个功能实现进行总结。实现采用html和css、JavaScript。
html页面实现了布局方式:
<!DOCTYPE html">
<html>
<head>
<title>New Document</title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<link rel="stylesheet" type="text/css" href="menu.css" media="all">
</head>
<script>
var nav4 = (function() {
bindClick = function(els, mask) {
if (!els || !els.length) {
return;
}
var isMobile = "ontouchstart" in window;
for ( var i = 0, ci; ci = els[i]; i++) {
ci.addEventListener("click", evtFn, false);
} function evtFn(evt, ci) {
ci = this;
for ( var j = 0, cj; cj = els[j]; j++) {
if (cj != ci) {
console.log(cj);
cj.classList.remove("on");
}
}
if (ci == mask) {
mask.classList.remove("on");
return;
}
switch (evt.type) {
case "click":
var on = ci.classList.toggle("on");
mask.classList[on ? "add" : "remove"]("on");
break;
}
}
mask.addEventListener(isMobile ? "touchstart" : "click", evtFn,
false);
};
return {
"bindClick" : bindClick
};
})();
</script>
<body>
<div class="bg">
<img src="home-default17.jpg" width="100%" height="100%;">
</div>
<div data-role="widget" data-widget="nav4" class="nav4">
<nav>
<div id="nav4_ul" class="nav_4">
<ul class="box">
<li>
<a href=""><span>我的卡通</span></a>
</li>
<li>
<a href=""><span>通通精彩</span></a>
</li>
<li>
<a href="javascript:;"><span>贴心服务</span></a>
<dl>
<dt>
<a href="http://3g.weimob.com"><span>贴心服务</span></a>
</dt>
<dt>
<a href=""><span>网点查询</span></a>
</dt>
<dt>
<a href="#"><span>集团服务</span></a>
</dt>
<dt>
<a href=""><span>线路查询</span></a>
</dt>
</dl>
</li>
</ul>
</div>
</nav>
<script type="text/javascript">
nav4.bindClick(document.getElementById("nav4_ul").querySelectorAll("li>a"), document.getElementById("nav4_masklayer"));
</script>
</div> </body></html>
css实现控制样式和布局:
*{padding:0; margin:0;}
.bg {
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
opacity: 0.8;
}
ul, ol, li, dl {
list-style-type: none;
}
.box {
width: 100%;
display: -webkit-box;
display: -moz-box;
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
.box > * {
-webkit-box-flex: 1;
-moz-box-flex: 1;
}
a:link, a:visited {
color: #575757;
text-decoration: none;
}
a {
text-decoration: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0.35);
}
a:link, a:visited {
color: #575757;
text-decoration: none;
}
a {
text-decoration: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0.35);
}
.nav4{
height:45px;
}
.nav4 ul{
position:fixed;
z-index:200;
bottom:0;
left:0;
width:100%
}
.nav4 li{
border:1px solid rgba(190,190,190,1);
height:45px;
border-bottom:0;
border-right:0;
position:relative;
-webkit-box-shadow:inset 0 0 3px #fff;
}
.nav4 li:nth-of-type(1){border-left;0;}
.nav4 li>a{
font-size:15px;
-webkit-box-sizing:border-box;
box-sizing:border-box;
/*border:1px solid #f9f8f9;*/
-webkit-tap-highlight-color:rgba(0,0,0,0);
border-bottom:0;
display:block;
line-height:45px;
text-align:center;
background:-webkit-gradient(linear, 0 0, 0 100%, from(#f1f1f1), to(#dcdcdc), color-stop(35% ,#ededed), color-stop(50%, #e3e3e3) );
}
.nav4 li>a:only-child span{
background:none;
padding-left:0;
}
.nav4 li>a.on + dl{
display: block;
}
.nav4 li>a span{
color: #4f4d4f;
display: inline-block;
padding-left: 15px;
background: url(1.svg#2) no-repeat 4px 18px;
-webkit-background-size: 9px auto;
text-shadow:0px 1px 0px #ffffff;
}
/***********************/
.nav4 dl{
display:none;
position:absolute;
z-index:220;
bottom:60px;
left:50%;
width:100px;
margin-left:-50px;
background:red;
/*min-height:100px;*/
background:#e4e3e2;
/*border:1px solid #afaeaf;*/
border-radius:5px;
-webkit-box-shadow:inset 0 0 3px #fff;
background:url(2.svg#3) no-repeat center center;
-webkit-background-size:100%;
background-size:100%;
}
/*, .nav4 dl:after*/
.nav4 dl:before{
content:"";
display:inline-block;
position:absolute;
z-index:240;
bottom:0;
left:50%;
/*width:0;
height:0;
border:8px solid red;
border-color:#afaeaf transparent transparent transparent;
margin-left:-8px;
margin-bottom:-16px;*/
width:10px;
height:8px;
background: url(1.svg#2) no-repeat center -55px;
-webkit-background-size: 10px auto;
bottom: -7px;
margin-left: -5px;
}
/*.nav4 dl:after{
z-index:241;
border-color:#e4e3e2 transparent transparent transparent;
margin-bottom:-15px;
}*/
.nav4 dl dd{
line-height:45px;
text-align:center;
background:-webkit-gradient(linear, 0 0, 100% 0, from(rgba(194,194,194,0.8)), to(rgba(194,194,194,0.8)), color-stop(50%, rgba(194,194,194,0.8)));
background-size:80% 1px;
background-repeat:no-repeat;
background-position: center bottom;
/*background: url(3.svg#4) no-repeat center bottom;
-webkit-background-size:100px 1px;*/
}
.nav4 dl dd:last-of-type{
background:none;
}
.nav4 dl dd a{
font-size: 15px;
display:block;
color:#4f4d4f;
text-shadow:0px 1px 0px #ffffff;
white-space: pre;
overflow: hidden;
text-overflow: ellipsis;
}
.nav4 .masklayer_div{
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 180;
background: rgba(0,0,0,0);
}
.nav4 .masklayer_div.on{display: block;}
.nav_4 ul{
list-style-type:none;
margin:0px;
padding:0;
}
.nav_4 ul li {
border: 1px solid rgba(190,190,190,1);
height: 45px;
width:33%;
border-bottom: 0;
border-right: 0;
position: relative;
float:left;
-webkit-box-shadow: inset 0 0 3px #fff;
}
.nav_4 dl {
display: none;
position: absolute;
z-index: 220;
bottom: 60px;
left: 50%;
width: 100px;
margin-left: -50px;
border-radius: 5px; /* 圆角边框 */
}
.nav_4 dl dt{
border:1px;
line-height: 45px;
text-align: center;
background: -webkit-gradient(linear, 0 0, 100% 0, from(rgba(194,194,194,0.8)), to(rgba(194,194,194,0.8)), color-stop(50%, rgba(194,194,194,0.8)));
background-size: 80% 1px;
background-repeat: no-repeat;
background-position: center bottom;
}
.nav_4 dl dt a{
font-size: 15px;
display: block;
color: #4f4d4f;
text-shadow: 0px 1px 0px #ffffff;
white-space: pre;
overflow: hidden;
text-overflow: ellipsis;
}
最后效果:

仿微信底部自定义菜单 移动web的更多相关文章
- html css 仿微信底部自己定义菜单
近期几个月一直从事微信开发,从刚開始的懵懂渐渐成长了一点. 今天认为微信底部自己定义菜单,假设能在html的页面上也能显示就好了. 记得曾经看过某个网页有类似效果.查找了该网页的css. ok如今h ...
- 微信 创建自定义菜单 向微信发起的post请求
微信 创建自定义菜单 向微信发起的post请求 Map<String, Object> res = new HashMap<String, Object>(); try { S ...
- php 微信3 自定义菜单
<pre name="code" class="php"><pre name="code" class="htm ...
- CI框架微信开发-自定义菜单
在CI框架下面实现了自定义菜单功能.写了一个model,一个类库.顺便附带access_token的实现方式 <?php class Makemenu{ public $menustr; pub ...
- <Android 基础(三十三)> TabHost ~ 仿微信底部菜单
简介 Container for a tabbed window view. This object holds two children: a set of tab labels that the ...
- react native仿微信性别选择-自定义弹出框
简述 要实现微信性别选择需要使用两部分的技术: 第一.是自定义弹出框: 第二.单选框控件使用: 效果 实现 一.配置弹出框 弹出框用的是:react-native-popup-dialog(Git地址 ...
- Android仿微信底部选项卡
第一步 添加依赖 dependencies { compile 'com.yinglan.alphatabs:library:1.0.5' } 第二步 布局使用 <?xml version=&q ...
- 简单的方法实现仿微信底部的Tab选项卡界面
在网上看了比较多的关于Tab的教程,发现都很杂乱.比较多的用法是用TitlePagerTabStrip和ViewPaper.不过TitlePagerTabStrip有个很大的缺陷,Tab里面的内容刚进 ...
- react-native聊天室|RN版聊天App仿微信实例|RN仿微信界面
一.前言 9月,又到开学的季节.为每个一直默默努力的自己点赞!最近都沉浸在react native原生app开发中,之前也有使用vue/react/angular等技术开发过聊天室项目,另外还使用RN ...
随机推荐
- Get it,你离几何达人不远了!
对于爱学几何的人,是否存在这样的困扰:没有标准的尺规工具,图形画的不标准,理解上总是出错......整天在纸上画图,浪费大把大把的时间......几何图形画的不美观,在别人面前都拿不出手,公开课上都没 ...
- js 通过身份证识别生日、年龄、性别
<script>function IdCard(UUserCard,num){ if(num==1){ //获取出生日期 birth=UUserCard.sub ...
- DIV 文字强制换行
一.对于div强制换行1.(IE浏览器)white-space:normal; word-break:break-all;这里前者是遵循标准.#wrap{white-space:normal; wid ...
- 【USACO 2.2】Subset Sums (DP)
N (1 <= N <= 39),问有多少种把1到N划分为两个集合的方法使得两个集合的和相等. 如果总和为奇数,那么就是0种划分方案.否则用dp做. dp[i][j]表示前 i 个数划分到 ...
- awk 匹配不是 pattern 的内容
awk '/pattern/ {next} {print $0}' filename
- CodeForces 37E Trial for Chief
Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Description Having ...
- [NOIP2012] 提高组 洛谷P1081 开车旅行
题目描述 小 A 和小 B 决定利用假期外出旅行,他们将想去的城市从 1 到 N 编号,且编号较小的 城市在编号较大的城市的西边,已知各个城市的海拔高度互不相同,记城市 i 的海拔高度为 Hi,城市 ...
- bzoj1124[POI2008]枪战maf
这代码快写死我了.....死人最多随便推推结论.死人最少,每个环可以单独考虑,每个环上挂着的每棵树也可以分别考虑.tarjan找出所有环,对环上每个点,求出选它和不选它时以它为根的树的最大独立集(就是 ...
- struts2 CVE-2014-0050(DoS), CVE-2014-0094(ClassLoader manipulation) S2-20 DoS attacks and ClassLoader manipulation
catalog . Description . Effected Scope . Exploit Analysis . Principle Of Vulnerability . Patch Fix 1 ...
- Android数据库升级
随着Android应用版本的迭代,经常遇到数据库表结构发生改变,或者一些指定的表数据需要更新.这也就引出一个问题Android数据库的更新问题. Android数据库升级分类 Android数据库更新 ...