<!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> <link rel="stylesheet" href="./css/style.css" /> </head> <style> * { list-style: none; margin: 0; padding: 0; text-decoration: none; } </style> <body> <!-- 外部容器 --> <div class="top-bar"> <!-- 左侧菜单 --> <div class="left-menu"> <!--菜单图标 --> <div class="menu-icon"></div> <li class="li1" id="lia"></li> <li class="li2" id="lia"></li> <li class="li3" id="lia"></li> </ul> <!-- 创建菜单 --> <ul class="naw"> <li class="li4"><a href="#">手机</a></li> <hr /> <li class="li5"><a href="#">美容仪器</a></li> <hr /> <li class="li6"><a href="#">配件</a></li> <hr /> <li class="li7"><a href="#">服务支持</a></li> <hr /> <li class="li8"><a href="#">企业网站</a></li> <li> <a href="#"><img src="/img/wu.png" /></a> <apan>搜索 Meitu.com</apan> </li> </ul> </div> <!-- logo --> <h1 class="logo"> <a href="/" style="color: aliceblue; ">美图手机</a> </h1> <!-- 用户信息 --> <div class="user-info"> <a href="#"> <img src="/img/si.png" /> </a> </div> </div> </body> </html>
/* 导航条的外部容器 */ .top-bar { height: 48px; padding: 0 14px; align-items: center; justify-content: space-between; background-color: black; display: flex; } /* 设置左侧导航图标 */ .left-menu { width: 18px; height: 48px; background-color: aliceblue; } .menu-icon { background-color: black; width: 18px; height: 48px; /* position: relative; */ } a { color: white; margin-left: 50px; } #lia { width: 18px; height: 5px; background-color: #ffffff; position: absolute; /* 修改原焦点 */ transform-origin: left center; transition: 0.2s; } .li1 { top: 18px; } .li2 { top: 24px; } .li3 { top: 30px; } .li1:hover { /* 向下旋转 */ transform: rotateZ(40deg); } .li2:hover { /* 隐藏 */ opacity: 0; } .li3:hover { transform: rotateZ(-40deg); } .naw { display: none; position: absolute; top: 48px; left: 0; bottom: 0; background-color: black; width: 100%; } .user-info { border: 5px red solid; } li { margin-bottom: 20px; } .logo { margin: 0 auto; } /* 设置媒体查询 */ @media only screen { /* 断点 768*/ @media (max-width: 768px) { .left-menu { order: 2; } .logo { order: 1; } .user-info { order: 3; } } }