html学习--------小米官网侧边栏模仿

在这里插入图片描述
在这里插入图片描述
效果图如上

代码:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- <link rel="stylesheet" href="learn.css"> -->
    <style>
        ul {
            /* 消除列表项前面的小黑点 */
            list-style: none;        
        }

        .nav {
            /* 设置类名为nav的div宽230px,高440px */
            width: 230px;
            height: 440px;
        }

        .nav ul {
            padding: 0 0;
        }

        .nav ul li a {
            display: block;
            width: 230px;
            height: 40px;
            line-height: 40px;
            color: #ccc;
            text-decoration: none;
            background-color: #55585a;
            text-indent: 40px;
        }

        .nav ul li div {
            width: 230px;
            height: 20px;
            background-color: #55585a;
        }

        .nav ul li a:hover {
            background-color: #ff6700;
        }
    </style>
</head>

<body>
    <!-- 用一个div,里面放一个无序列表,每一个列表项里放一个链接(除了首位列表项) -->
   <div class="nav">        
       <ul>
           <li><div></div></li>
           <li><a href="#">手机 电话卡</a></li>
           <li><a href="#">电视 盒子</a></li>
           <li><a href="#">笔记本 显示器</a></li>
           <li><a href="#">家电 插线板</a></li>
           <li><a href="#">出行 穿戴</a></li>
           <li><a href="#">智能 路由器</a></li>
           <li><a href="#">电源 配件</a></li>
           <li><a href="#">健康 儿童</a></li>
           <li><a href="#">耳机 音箱</a></li>
           <li><a href="#">生活 箱包</a></li>
           <li><div></div></li>
       </ul>
   </div>
</body>

</html>

有问题可直接私信或评论问我,做的一般,请大佬们轻点喷。。。。。。

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Vue-element-admin 是一个基于 Vue.js 和 Element UI 的后台管理系统解决方案。它提供了许多常用的后台管理功能和组件,包括侧边、面包屑导航、表格、表单、图表等等。 侧边是 Vue-element-admin 中的一个重要组件,它通常用于展示系统的菜单和功能项。在 Vue-element-admin 中,侧边是通过路由配置来生成的。 在路由配置中,每一个路由配置项对应着一个菜单项。菜单项包括菜单的标题、图标、路径、子菜单等信息。当用户点击菜单项时,就会跳转到对应的路由页面。 以下是一个简单的示例,演示如何使用 Vue-element-admin 的侧边组件: ```javascript // 路由配置 const routes = [ { path: '/', redirect: '/dashboard' }, { path: '/dashboard', component: Layout, children: [ { path: '', name: 'Dashboard', component: () => import('@/views/dashboard/index'), meta: { title: 'Dashboard', icon: 'dashboard' } } ] }, { path: '/example', component: Layout, redirect: '/example/table', name: 'Example', meta: { title: 'Example', icon: 'example' }, children: [ { path: 'table', name: 'Table', component: () => import('@/views/table/index'), meta: { title: 'Table', icon: 'table' } }, { path: 'tree', name: 'Tree', component: () => import('@/views/tree/index'), meta: { title: 'Tree', icon: 'tree' } } ] } ] // 侧边组件 <template> <el-menu :default-active="activeIndex" class="el-menu-vertical-demo" :collapse="isCollapse"> <template v-for="(item, index) in menuList"> <el-submenu v-if="item.children" :key="index" :index="index"> <template slot="title"> <i :class="item.icon"></i> <span slot="title">{{item.title}}</span> </template> <template v-for="(subItem, subIndex) in item.children"> <el-menu-item :key="index + '-' + subIndex" :index="index + '-' + subIndex" @click="handleMenuClick(subItem)"> <i :class="subItem.icon"></i> <span slot="title">{{subItem.title}}</span> </el-menu-item> </template> </el-submenu> <el-menu-item v-else :key="index" :index="index" @click="handleMenuClick(item)"> <i :class="item.icon"></i> <span slot="title">{{item.title}}</span> </el-menu-item> </template> </el-menu> </template> <script> export default { props: { menuList: { type: Array, required: true }, activeIndex: { type: String, required: true }, isCollapse: { type: Boolean, required: true } }, methods: { handleMenuClick(item) { this.$emit('menu-click', item) } } } </script> ``` 在这个示例中,路由配置包含了三个路由项,分别对应 Dashboard、Table 和 Tree 三个菜单项。侧边组件则使用了 Element UI 中的 Menu 组件来展示菜单项。侧边组件的主要作用是传递菜单项列表、当前选中的菜单项和侧边是否折叠等参数,以及监听菜单项的点击事件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值