<body> <div class="index_main"> <div id="progress-bar"></div> <div id="menu-container" class="header_"> </div> </div> <script src="../static/JS/menu.js"></script> <script src="../static/JS/jindu.js"></script> </body>该菜单如何在添加图标和文本
时间: 2024-04-14 12:02:21 浏览: 25
要在菜单中添加图标和文本,你可以根据以下示例代码进行修改:
```html
<!DOCTYPE html>
<html>
<head>
<style>
.index_main {
position: relative;
}
#progress-bar {
position: fixed;
top: 0;
left: 0;
width: 0%;
height: 3px;
background-color: blue;
z-index: 9999;
transition: width 0.3s ease-out;
}
.menu-container {
width: 50px; /* 初始宽度 */
background-color: #f1f1f1;
overflow: hidden;
transition: width 0.3s ease-out;
}
.menu-container:hover {
width: 200px; /* 扩展后的宽度 */
}
.menu-icon {
display: inline-block;
width: 20px;
height: 20px;
background-image: url('path_to_icon.png'); /* 替换为你的图标路径 */
background-size: cover;
margin-right: 5px;
}
.menu-text {
display: inline-block;
opacity: 0; /* 初始隐藏文本 */
transition: opacity 0.3s ease-out;
}
.menu-container:hover .menu-text {
opacity: 1; /* 鼠标悬停时显示文本 */
}
</style>
</head>
<body>
<div class="index_main">
<div id="progress-bar"></div>
<div id="menu-container" class="header_">
<div class="menu-item">
<div class="menu-icon"></div>
<div class="menu-text">菜单文本1</div>
</div>
<div class="menu-item">
<div class="menu-icon"></div>
<div class="menu-text">菜单文本2</div>
</div>
</div>
</div>
<script src="../static/JS/menu.js"></script>
<script src="../static/JS/jindu.js"></script>
</body>
</html>
```
根据上述代码,你可以在`menu-container`中添加多个`menu-item`用于显示不同的图标和文本。你需要将每个`menu-icon`的`background-image`属性替换为相应图标的路径。
当鼠标悬停在菜单容器上时,菜单容器的宽度会扩展,并且文本的`opacity`属性会变为1,以显示出文本。
希望这个示例能够满足你的需求。如果还有其他问题,请随时提问。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
請你幫我打修改HTML代碼<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>异常记录</title> <style> .main { display: flex; flex-direction: row; justify-content: space-between; align-items: center; } </style> </head> <body> 首页 登记数据 查询数据 异常记录登记 <form method="post" action="/submit"> <label>确认线别:</label> <input type="text" name="line">
<label>确认日期:</label> <input type="date" name="date">
<label>异常机种:</label> <input type="text" name="model">
<label>异常现象:</label> <textarea name="issue"></textarea>
<label>生产日期:</label> <input type="date" name="prod_date">
<label>生产班别:</label> <input type="text" name="shift">
<label>生产线别:</label> <input type="text" name="prod_line">
<label>责任人:</label> <input type="text" name="responsible">
<input type="submit" value="提交"> </form> 欢迎访问 </body> </html>
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<html> <head> <meta charset="utf-8" /> <title>星星国际影城</title> <script src="js/main.js" type="text/javascript"></script> </head> <body> 登录| 注册| 全国服务热线:888-8888888 < img src="images/logo.jpg" title="" alt="logo" /> 首页 影片 影城 购票 影城活动 会员服务 顾客互动 <input type="text" placeholder="搜索影片" name="search"/> <input type="button" name="btn" value="" /> < img src="images/b1.png" /> < img src="images/b2.png" /> < img src="images/b3.png" /> 在每行代码进行解释
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
样式优化美化<!DOCTYPE html> {% load static %} <html> <head> <title>个人中心</title> <style> .container { display: flex; flex-wrap: wrap; justify-content: space-between; } .module { width: calc(25% - 20px); margin-bottom: 20px; padding: 20px; border: 1px solid #ccc; border-radius: 5px; } @media (max-width: 768px) { .module { width: calc(50% - 20px); } } @media (max-width: 480px) { .module { width: 100%; } } </style> </head> <body> 个人信息 <form> <label for="username">用户名:</label> <input type="text" id="username"> <label for="email">邮箱:</label> <input type="email" id="email"> <button type="submit">保存</button> </form> 修改密码 <form> <label for="old-password">旧密码:</label> <input type="password" id="old-password"> <label for="new-password">新密码:</label> <input type="password" id="new-password"> <label for="confirm-password">确认密码:</label> <input type="password" id="confirm-password"> <button type="submit">保存</button> </form> 绑定手机 <form> <label for="phone">手机号:</label> <input type="tel" id="phone"> <button type="submit">保存</button> </form> 我的消息 系统消息1 系统消息2 好友消息1 好友消息2 </body> </html>
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
删除这个代码中的Javascripts语句让它只用HTML和css实现。 商品 关于Cake's Dream 食品经营许可证 联系我们 购物车页面
<script src="assets/javascripts/jquery.js"></script> <script src="assets/javascripts/fancybox/jquery.fancybox.pack.js"></script> <script src="assets/javascripts/slick.js"></script> <script src="assets/javascripts/wow/wow.js"></script> <script src="assets/javascripts/custom.js"></script> <script src="assets/javascripts/bootstrap.js"></script> <script src="assets/javascripts/classie.js"></script> <script src="assets/javascripts/pathLoader.js"></script> <script src="assets/javascripts/main.js"></script> <script type="text/javascript"> new WOW().init(); </script> <style> </body> </html>
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<html> <head> <meta charset="UTF-8"> <title>星星国际影城-用户登录界面</title> <script src="js/login.js"></script> </head> <body> xx国际影城 <form action="#" method="post"> <label>用户名:</label> <input type="text" placeholder="请输入用户名" name="userName" value=""/> <label>密 码:</label> <input type="password" placeholder="请输入密码" name="password" value=""/> 登录 </form> 还不是我们的会员?立即注册 </body> </html>。在每行代码后面加上解释
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
<title>医院住院管理系统</title> </head> <body> 药品发放 <form id="drugs_delivery"> <label>*住院号:</label> <input results="s" type="search" readonly name="patientId" id="patientId" /> <label>*姓名:</label> <input type="text" readonly name="patientName" id="patientName" /> <label>*药品编号:</label> <input type="search" results="s" readonly name="drugId" id="drugsId" /> <label>数量:</label> <input type="text" name="drugCount" id="num" onblur="checkdrugsnum()" /> <input type="hidden" name="num1" id="num1"> <label>*药品名称:</label> <p cla
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)