当前位置:网站首页>动态菜单,自动对齐
动态菜单,自动对齐
2022-06-24 19:39:00 【高彬】
描述:类似微信公众号菜单样式,子菜单动态生成数量不固定,样式如下:

html
<nav class="wx_menu">
<dl>
<dt>短信/资费</dt>
<dd>
<ul class="dropdown-menu">
<li><a href="/wx/m/sms">短信</a></li>
<li><a href="/wx/m/data">流量</a></li>
<li><a href="/wx/m/price">资费</a></li>
<li><a href="/wx/m/partner">合伙人</a></li>
</ul>
</dd>
</dl>
<dl>
<dt>
推广/兑换
</dt>
<dd>
<ul class="dropdown-menu">
<li><a href="/wx/m/partner_plan">积分介绍</a></li>
<li><a href="/WX/m/Extension/@ViewBag.MySharedInfo">推广会员</a></li>
<li><a href="/wx/wx_jfdd/shop">兑换礼品</a></li>
<li><a href="/wx/WX_FXJL/exshare">兑换积分</a></li>
</ul>
</dd>
</dl>
<dl>
<dt>我的</dt>
<dd>
<ul class="dropdown-menu">
<li><a href="/wx/WX_JFJL/myscore">积分</a></li>
<li><a href="/wx/WX_FXJL/myshare">分享值</a></li>
<li><a href="/WX/WX_HHR/mymember">会员</a></li>
<li><a href="/WX/WX_HHR/myinfo">资料</a></li>
<li><a href="/WX/WX_HHR/myaddress">收件地址</a></li>
</ul>
</dd>
</dl>
</nav>
css(less)
.wx_menu {
width: 100%;
position: fixed;
bottom: 0;
left: 0;
right: 0;
margin: auto;
z-index: 200000;
background-color: transparent;
text-align: center;
dl {
background-color: #fff;
border: solid 1px #ddd9d9;
text-align: center;
padding: 10px 0;
margin-bottom: 4px;
position: relative;
display: inline-block;
width: 30%;
dd {
display: none;
width: 100%;
margin: 0 0 6px 0;
padding: 0;
transition: 1s;
animation: flipInX,.4s,1;
position: absolute;
top: auto;
bottom: 100%;
}
}
ul {
display: block;
width: 100%;
margin: 0;
padding: 0;
box-shadow: 0,2px,4px,#000;
li {
display: block;
padding: 12px 0;
text-align: center;
background-color: #fff;
width: 100%;
box-sizing: border-box;
border: 1px solid #e0e0e0;
}
li:not(:last-child) {
border-bottom: none;
}
}
}
js
$(function () {
$(".wx_menu").find("dt").click(function () {
var _obj = $(this);
if (_obj.next("dd").css("display") == "block") {
_obj.next("dd").css({ "display": "none" });
} else {
_obj.next("dd").css({ "display": "block" }).parent().siblings().find("dd").hide();
}
});
});本例是底部对齐,关键样式是: top: auto;bottom: 100%;
边栏推荐
- Concurrency of heap memory allocation
- 网上立案流程
- Basic principles of layer 2 switching
- 环境配置 | VS2017配置OpenMesh源码和环境
- OA system -- save the verification code to session
- Leetcode: calculate the number of elements less than the current element on the right (sortedlist+bisect\u left)
- vulnhub Vegeta: 1
- Web security XSS foundation 06
- NiO zero copy
- Cross border e-commerce, early entry and early benefit
猜你喜欢

Genesis public chain and a group of encryption investors in the United States gathered in consensus 2022

Kubevela v1.2 release: the graphical operation console velaux you want is finally here

【个人实验报告】
How to solve the problem that the computer suddenly can't connect to WiFi

Principles of Ethernet port mirroring, link aggregation and VLAN Technology

Win10 or win11 printer cannot print

【Mongodb】READ_ ME_ TO_ RECOVER_ YOUR_ Data, the database is deleted maliciously

网上立案流程

vulnhub DC: 2

Nuscenes -- remedies for missing image files or 0-size images encountered during dataset configuration
随机推荐
Online filing process
Are you afraid of being asked MySQL related questions during the interview? This 30000 word essence summary + 100 interview questions, and it's enough to hang the interviewer
Genesis公链与美国一众加密投资者齐聚Consensus 2022
Source code reading | the process of reading text format STL by openmesh
倍加福(P+F)R2000修改雷达IP
NiO, bio, AIO
NIO、BIO、AIO
结构体的内存对齐
大厂面试必问:如何解决TCP可靠传输问题?8张图带你详细学习
NIO、BIO、AIO
seven
【ROS玩转Turtlesim小海龟】
See how sparksql supports enterprise level data warehouse
Problem solving - nested lists
Use of selector for NiO multiplexing
Tetris
See how sparksql supports enterprise level data warehouse
The core concept of JMM: happens before principle
High level application of SQL statements in MySQL database (I)
LeetCode Algorithm 剑指 Offer 52. 两个链表的第一个公共节点