标签:微信 100% h5 width nav 跳转 font display block
在开发微信公众号时,有两个菜单需跳转至小程序。
由于菜单项是通过循环遍历出的,直接使用 wx-open-launch-weapp
包裹住菜单项,发现在浏览器调试时,并不显示
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.nav a {
display: block;
text-align: center;
border: 1px solid rgb(126, 115, 115);
width: 100px;
height: 100px;
margin: 10px;
}
.nav a i {
display: block;
margin: 0 auto;
width: 65px;
height: 65px;
}
.nav a i img {
display: block;
width: 100%
}
.nav a strong {
display: block;
font-size: 14px;
color: #333;
font-weight: 200;
}
</style>
</head>
<body>
<div class="nav">
<a href="javascript:void(0);">
<wx-open-launch-weapp style="width: 100%; height: 100%;" path="pages/webview/webview" username="gh_test1account">
<script type="text/wxtag-template">
<style>
img {
display: block;
width: 100%;
}
strong {
display: block;
font-size: 12px;
color: #333;
font-weight: 200;
}
</style>
<div class="toWrap">
<i>
<img src="https://img1.baidu.com/it/u=1955340679,2837494472&fm=26&fmt=auto">
</i>
<strong>来院导航</strong>
</div>
</script>
</wx-open-launch-weapp>
</a>
</div>
</body>
</html>
因此,采用plan B,在原菜单项上加一个div放置weapp组件,并定位在父元素上方,此时菜单可显示,且点击也可跳转。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.nav a {
display: block;
text-align: center;
border: 1px solid rgb(126, 115, 115);
width: 100px;
height: 100px;
margin: 10px;
}
.nav a i {
display: block;
margin: 0 auto;
width: 65px;
height: 65px;
}
.nav a i img {
display: block;
width: 100%
}
.nav a strong {
display: block;
font-size: 14px;
color: #333;
font-weight: 200;
}
.originA {
position: relative;
}
.weappContainer {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
</style>
</head>
<body>
<div class="nav">
<a href="javascript:void(0);" class="originA">
<i><img src="https://img1.baidu.com/it/u=1955340679,2837494472&fm=26&fmt=auto"></i>
<strong>来院导航</strong>
<div class="weappContainer">
<wx-open-launch-weapp style="width: 100%; height: 100%;" path="pages/webview/webview"
username="gh_test1account">
<script type="text/wxtag-template">
<style>
.toWrap{
display: flex;flex-direction: column;align-items: center;
width: 100%;
height: 100%;
opacity: 0;
}
img {
display: block;
width: 100%;
}
strong {
display: block;
font-size: 12px;
color: #333;
font-weight: 200;
}
</style>
<div class="toWrap">
<i>
<img src="https://img1.baidu.com/it/u=1955340679,2837494472&fm=26&fmt=auto">
</i>
<strong>来院导航</strong>
</div>
</script>
</wx-open-launch-weapp>
</div>
</a>
</div>
</body>
</html>
标签:微信,100%,h5,width,nav,跳转,font,display,block 来源: https://blog.csdn.net/Day71/article/details/121105211
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。