ul 下 li 超出多余margin 让ul 减去多余margin

每个li margin-right:20px;

ul margin-right:-20px;

优化下面的代码,解决数据显示区域被侧边栏挡住部分的情况,然后解决大模块展开后与第一个子模块在一起的情况<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>后台管理界面示例</title> <style> body { margin: 0; padding: 0; font-family: Arial, Helvetica, sans-serif; } header { background-color: #333; color: #fff; display: flex; justify-content: space-between; align-items: center; padding: 20px 20px 20px 20px; position: fixed; top: 0; left: 0; right: 0; z-index: 1; } header h1 { margin: 0; font-size: 24px; } header .user { display: flex; align-items: center; cursor: pointer; } header .user img { width: 30px; height: 30px; border-radius: 50%; margin-right: 10px; } .sidebar { background-color: #eee; position: fixed; top: 70px; left: 0; bottom: 0; width: 200px; padding: 10px; overflow: auto; z-index: 1; } .sidebar h2 { margin: 0; font-size: 18px; margin-bottom: 10px; } .sidebar ul { padding: 0; margin: 0; list-style: none; } .sidebar li { margin-bottom: 5px; } .sidebar a { display: block; padding: 5px 10px; color: #333; border-radius: 5px; text-decoration: none; background-color: #fff; transition: background-color 0.2s ease-in-out; } .sidebar a:hover { background-color: #ddd; } .content { margin: 60px 0 0 20px; padding: 10px; background-color: #f5f5f5; min-height: 100vh; margin-left: 200px; } </style> </head> <body> <header> <h1>中央管理平台</h1> <div class="user"> <img src="user.png" alt=""> <span>未登录</span> </div> </header> <div class="sidebar"> <h2>功能模块</h2> <ul> <li> <a href="#">用户管理</a> <ul> <li><a href="#">添加用户</a></li> <li><a href="#">删除用户</a></li> <li><a href="#">修改用户</a></li> </ul> </li> <li> <a href="#">数据库管理</a> <ul> <li><a href="#">备份数据库</a></li> <li><a href="#">还原数据库</a></li> </ul> </li> <li> <a href="#">页面管理</a> <ul> <li><a href="#">添加页面</a></li> <li><a href="#">删除页面</a></li> <li><a href="#">修改页面</a></li> </ul> </li> </ul> </div> <div class="content"> <!-- 这里是内容区域 --> </div> <script> // 模拟后端数据传来时,只刷新头部和侧边栏之外的区域 setTimeout(() => { document.querySelector('.content').innerHTML = '<h2>欢迎使用中央管理平台</h2><p>这里是内容区域,只有在后端有数据传来时才会刷新。</p>'; }, 3000); </script> </body> </html>
最新发布
05-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值