点击查看【bilibili】
本案例使用flex布局,hover效果使用了垂直居中,运用了一些动画效果(transform,translate)
思路
<a name="hEYay"></a>### css```css* {margin: 0;padding: 0;}#menu-overlay {position: fixed;top: 0;left: 0;right: 0;bottom: 0;background-color: #f00;display: flex;justify-content: center;align-items: center;/* 垂直方向溢出产生滚动条 */overflow-y: auto;transform: scale(0);/* 添加过渡 */transition: 0.5s;}#menu-overlay.active {transform: scale(1);}#menu-overlay ul li {list-style: none;text-align: center;display: block;}#menu-overlay ul li a {position: relative;text-decoration: none;font-size: 3.5em;padding: 0 10px;color: #fff;font-weight: 700;/* 改为大写 */text-transform: uppercase;display: inline-block;}/* 使用伪元素的方式添加中间的黄色横条 */#menu-overlay ul li a:before {content: '';position: absolute;top: 50%;left: 0;width: 100%;height: 8px;background: #ff0;transform: translateY(-50%) scaleX(0);transform-origin: right;transition: 0.5s transform;}#menu-overlay ul li a:hover:before {transform: translateY(-50%) scaleX(1);transform-origin: left;transition: 0.5s transform;}#toggleIcon {/* 固定在右上角 */position: fixed;top: 20px;right: 20px;width: 50px;height: 50px;z-index: 1;cursor: pointer;background: #ff0 url(open.png);transition: 0.5s;}#toggleIcon.active {background: #ff0 url(close.png);}
